Skip to content

Commit

Permalink
Merge pull request #67 from lara-zeus/fixes-updates
Browse files Browse the repository at this point in the history
fixes and updates
  • Loading branch information
atmonshi authored Aug 30, 2023
2 parents 36e79af + af71b16 commit a4c33f8
Show file tree
Hide file tree
Showing 18 changed files with 1,761 additions and 717 deletions.
2,320 changes: 1,655 additions & 665 deletions composer.lock

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions database/factories/DepartmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use LaraZeus\Wind\WindPlugin;

class DepartmentFactory extends Factory /* @phpstan-ignore-line */
class DepartmentFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*/
public function getModel(): string
{
return WindPlugin::get()->getDepartmentModel();
}

/**
* Define the model's default state.
*/
public function definition(): array
{
return [
Expand Down
11 changes: 3 additions & 8 deletions database/factories/LetterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@
namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use LaraZeus\Wind\Models\Department;
use LaraZeus\Wind\WindPlugin;

class LetterFactory extends Factory /* @phpstan-ignore-line */
class LetterFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*/
public function getModel(): string
{
return WindPlugin::get()->getDepartmentModel();
}

/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'name' => $this->faker->name,
'email' => $this->faker->email,
'department_id' => WindPlugin::get()->getDepartmentModel()::factory(),
'department_id' => Department::factory(),
'title' => $this->faker->words(3, true),
'message' => $this->faker->words(5, true),
'status' => 'NEW',
Expand Down
3 changes: 1 addition & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ parameters:
level: 6
paths:
- src
- config
- database
- tests
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
5 changes: 0 additions & 5 deletions resources/views/themes/zeus/wind/contact-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
</x-slot>

<x-slot name="breadcrumbs">
<li class="flex items-center">
<a href="{{ url('/') }}">{{ __('Home') }}</a>
@svg('iconpark-rightsmall-o','fill-current w-4 h-4 mx-3 rtl:rotate-180')
</li>

<li class="flex items-center">
{{ __('Contact us') }}
</li>
Expand Down
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

use Illuminate\Support\Facades\Route;
use LaraZeus\Wind\Http\Livewire\ContactsForm;
use LaraZeus\Wind\Livewire\ContactsForm;
use LaraZeus\Wind\WindPlugin;

if (app('filament')->hasPlugin('zeus-wind')) {
if (! defined('__PHPSTAN_RUNNING__') && app('filament')->hasPlugin('zeus-wind')) {
Route::middleware(WindPlugin::get()->getMiddleware())
->prefix(WindPlugin::get()->getWindPrefix())
->get('{departmentSlug?}', ContactsForm::class)
Expand Down
3 changes: 0 additions & 3 deletions src/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public function handle()
$this->callSilent('vendor:publish', ['--tag' => 'zeus-wind-migrations', '--force' => (bool) $this->option('force')]);
$this->callSilent('vendor:publish', ['--tag' => 'zeus-wind-translations', '--force' => (bool) $this->option('force')]);

$this->callSilent('vendor:publish', ['--tag' => 'zeus-wind-seeder', '--force' => (bool) $this->option('force')]);
$this->callSilent('vendor:publish', ['--tag' => 'zeus-wind-factories', '--force' => (bool) $this->option('force')]);

// publish Zeus files
$this->callSilent('vendor:publish', ['--tag' => 'zeus-config', '--force' => (bool) $this->option('force')]);
$this->callSilent('vendor:publish', ['--tag' => 'zeus-views', '--force' => (bool) $this->option('force')]);
Expand Down
5 changes: 2 additions & 3 deletions src/Events/LetterSent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LaraZeus\Wind\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -28,10 +29,8 @@ public function __construct(Letter $letter)

/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
public function broadcastOn(): Channel | PrivateChannel | array
{
return new PrivateChannel('zeus-wind');
}
Expand Down
5 changes: 2 additions & 3 deletions src/Events/ReplySent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LaraZeus\Wind\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -28,10 +29,8 @@ public function __construct(Letter $letter)

/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
public function broadcastOn(): Channel | PrivateChannel | array
{
return new PrivateChannel('zeus-wind');
}
Expand Down
3 changes: 1 addition & 2 deletions src/Filament/Resources/LetterResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use LaraZeus\Wind\Filament\Resources\LetterResource\Pages;
use LaraZeus\Wind\Models\Letter;
Expand Down Expand Up @@ -185,7 +184,7 @@ public static function table(Table $table): Table
]),
]),
])
->recordClasses(fn (Model $record) => match ($record->status) {
->recordClasses(fn (Letter $record) => match ($record->status) {
'NEW' => 'border-s-2 border-danger-600 dark:border-danger-300',
'REPLIED' => 'border-s-2 border-gray-600 dark:border-gray-300',
'READ' => 'border-s-2 border-success-600 dark:border-success-300',
Expand Down
4 changes: 3 additions & 1 deletion src/Filament/Resources/LetterResource/Pages/EditLetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace LaraZeus\Wind\Filament\Resources\LetterResource\Pages;

use Filament\Resources\Pages\EditRecord;
use LaraZeus\Wind\Events\ReplySent;
use LaraZeus\Wind\Filament\Resources\LetterResource;
use LaraZeus\Wind\WindPlugin;

Expand All @@ -17,7 +18,7 @@ public function mount(int | string $record): void
{
parent::mount($record);

if ($this->record->reply_message !== null && strtoupper($this->record->status) === WindPlugin::get()->getDefaultStatus()) {
if ($this->record->reply_message === null && strtoupper($this->record->status) === WindPlugin::get()->getDefaultStatus()) {
$this->record->update(['status' => 'READ']);
}
}
Expand All @@ -26,6 +27,7 @@ protected function afterSave(): void
{
if ($this->record->reply_message !== null) {
$this->record->update(['status' => 'REPLIED']);
ReplySent::dispatch($this->record);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LaraZeus\Wind\Http\Livewire;
namespace LaraZeus\Wind\Livewire;

use Filament\Forms;
use Filament\Forms\Components\Grid;
Expand Down
6 changes: 2 additions & 4 deletions src/Models/Department.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class Department extends Model
use SoftDeletes;
use HasFactory;

protected $fillable = [
'name', 'is_active', 'user_id', 'ordering', 'desc', 'options', 'logo', 'start_date', 'end_date', 'slug',
];
protected $guarded = [];

protected $casts = [
'start_date' => 'datetime',
Expand Down Expand Up @@ -71,6 +69,6 @@ public function image(): ?string

public function scopeDepartments(Builder $query): void
{
$query->whereIsActive(true)->orderBy('ordering');
$query->where('is-active', true)->orderBy('ordering');
}
}
4 changes: 1 addition & 3 deletions src/Models/Letter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class Letter extends Model
use SoftDeletes;
use HasFactory;

protected $fillable = [
'name', 'email', 'department_id', 'title', 'message', 'status', 'reply_message', 'reply_title',
];
protected $guarded = [];

protected static function newFactory(): LetterFactory
{
Expand Down
9 changes: 5 additions & 4 deletions src/WindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use LaraZeus\Wind\Filament\Resources\DepartmentResource;
use LaraZeus\Wind\Filament\Resources\LetterResource;

class WindPlugin implements Plugin
final class WindPlugin implements Plugin
{
use Configuration;

Expand All @@ -32,12 +32,13 @@ public function register(Panel $panel): void

public static function make(): static
{
return app(static::class);
return new self();
}

public static function get(): Plugin | \Filament\FilamentManager
public static function get(): static
{
return filament(app(static::class)->getId());
// @phpstan-ignore-next-line
return filament('zeus-wind');
}

public function boot(Panel $panel): void
Expand Down
4 changes: 1 addition & 3 deletions src/WindServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

use LaraZeus\Core\CoreServiceProvider;
use LaraZeus\Wind\Commands\PublishCommand;
use LaraZeus\Wind\Http\Livewire\Contacts;
use LaraZeus\Wind\Http\Livewire\ContactsForm;
use LaraZeus\Wind\Livewire\ContactsForm;
use Livewire\Livewire;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand All @@ -18,7 +17,6 @@ public function packageBooted(): void
{
CoreServiceProvider::setThemePath('wind');

Livewire::component('contact', Contacts::class);
Livewire::component('contact-form', ContactsForm::class);

if ($this->app->runningInConsole()) {
Expand Down
51 changes: 51 additions & 0 deletions tests/AdminPanelProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace LaraZeus\Wind\Tests;

use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\SpatieLaravelTranslatablePlugin;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use LaraZeus\Wind\WindPlugin;

class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->login()
->plugins([
WindPlugin::make(),
SpatieLaravelTranslatablePlugin::make()
->defaultLocales(['en']),
])
->registration()
->passwordReset()
->emailVerification()
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
]);
}
}
31 changes: 30 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

namespace LaraZeus\Wind\Tests;

use ArchTech\SEO\SEOServiceProvider;
use BladeUI\Heroicons\BladeHeroiconsServiceProvider;
use BladeUI\Icons\BladeIconsServiceProvider;
use Codeat3\BladeIconpark\BladeIconparkServiceProvider;
use Filament\Actions\ActionsServiceProvider;
use Filament\FilamentServiceProvider;
use Filament\Forms\FormsServiceProvider;
use Filament\Infolists\InfolistsServiceProvider;
use Filament\Notifications\NotificationsServiceProvider;
use Filament\SpatieLaravelTranslatablePluginServiceProvider;
use Filament\Support\SupportServiceProvider;
use Filament\Tables\TablesServiceProvider;
use Filament\Widgets\WidgetsServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use LaraZeus\Core\CoreServiceProvider;
use LaraZeus\Wind\WindServiceProvider;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider;

class TestCase extends Orchestra
{
Expand All @@ -22,9 +36,24 @@ protected function setUp(): void
protected function getPackageProviders($app)
{
return [
LivewireServiceProvider::class,
ActionsServiceProvider::class,
BladeCaptureDirectiveServiceProvider::class,
BladeHeroiconsServiceProvider::class,
BladeIconsServiceProvider::class,
FilamentServiceProvider::class,
FormsServiceProvider::class,
InfolistsServiceProvider::class,
LivewireServiceProvider::class,
NotificationsServiceProvider::class,
SpatieLaravelTranslatablePluginServiceProvider::class,
SupportServiceProvider::class,
TablesServiceProvider::class,
WidgetsServiceProvider::class,
AdminPanelProvider::class,
CoreServiceProvider::class,
WindServiceProvider::class,
SEOServiceProvider::class,
BladeIconparkServiceProvider::class,
];
}

Expand Down

0 comments on commit a4c33f8

Please sign in to comment.