-
-
Notifications
You must be signed in to change notification settings - Fork 15
feat:[LAR-33] Add filament channel crud in cpanel with feature test #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mckenziearts
merged 7 commits into
develop
from
feature/lar-33-admin-filament-listing-des-channels-de-thread
Nov 8, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6661b64
feat:[LAR-33] Add filament channel crud in cpanel with feature test
cybersoldattech ee78ed9
feat: [LAR-33] Remove Edit and Page and add SliveOver , Add Channel …
cybersoldattech 7839275
feat: (LAR-20) add xp to dashboard user (#202)
StevyMarlino 452f9ae
chore(deps): bump spatie/laravel-permission from 5.11.1 to 6.10.0 (#199)
dependabot[bot] c1488f8
chore(deps-dev): bump laravel-vite-plugin from 0.7.8 to 1.0.5 (#194)
dependabot[bot] 856810e
chore(deps-dev): bump postcss-loader from 6.2.1 to 8.1.1 (#195)
dependabot[bot] 60fe6a5
chore(deps-dev): bump @ryangjchandler/alpine-tooltip from 1.3.1 to 2.…
dependabot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\ChannelResource\Pages; | ||
use App\Models\Channel; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Support\Enums\MaxWidth; | ||
use Filament\Tables; | ||
use Filament\Tables\Actions\ActionGroup; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Support\Str; | ||
|
||
final class ChannelResource extends Resource | ||
{ | ||
protected static ?string $model = Channel::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-queue-list'; | ||
|
||
public static function getLabel(): string | ||
{ | ||
return __('Channels'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\Section::make() | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->live(onBlur: true) | ||
->afterStateUpdated(function (string $operation, $state, Forms\Set $set): void { | ||
$set('slug', Str::slug($state)); | ||
}), | ||
Forms\Components\TextInput::make('slug') | ||
->readOnly() | ||
->helperText(__('Cette valeur est générée dynamiquement en fonction du Name.')), | ||
Forms\Components\Select::make('parent_id') | ||
->relationship('parent', 'name', fn (Builder $query) => $query->whereNull('parent_id')) | ||
->default(null), | ||
Forms\Components\TextInput::make('color') | ||
->maxLength(255) | ||
->type('color'), | ||
Forms\Components\Textarea::make('description.fr') | ||
->label('Description') | ||
->columnSpanFull(), | ||
]) | ||
->columnSpan(['lg' => 2]), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('slug') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('parent.name') | ||
->numeric() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('thread_number') | ||
->label('Nombre de thead') | ||
->getStateUsing(fn ($record) => $record->threads()->count()), | ||
Tables\Columns\TextColumn::make('color') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->filters([ | ||
|
||
]) | ||
->actions([ | ||
ActionGroup::make([ | ||
Tables\Actions\DeleteAction::make(), | ||
Tables\Actions\EditAction::make() | ||
->slideOver() | ||
->modalWidth(MaxWidth::Large), | ||
]), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListChannels::route('/'), | ||
]; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/Filament/Resources/ChannelResource/Pages/ListChannels.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\ChannelResource\Pages; | ||
|
||
use App\Filament\Resources\ChannelResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
use Filament\Support\Enums\MaxWidth; | ||
|
||
final class ListChannels extends ListRecords | ||
{ | ||
protected static string $resource = ChannelResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make() | ||
->slideOver() | ||
->modalWidth(MaxWidth::Large), | ||
]; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Filament\Resources\ChannelResource; | ||
use App\Filament\Resources\ChannelResource\Pages\ListChannels; | ||
use App\Models\Channel; | ||
use Filament\Actions\CreateAction; | ||
use Filament\Actions\EditAction; | ||
use Livewire\Livewire; | ||
|
||
beforeEach(function (): void { | ||
$this->user = $this->login(); | ||
}); | ||
|
||
describe(ChannelResource::class, function (): void { | ||
it('page can display table with records', function (): void { | ||
$channels = Channel::factory() | ||
->count(10) | ||
->create(); | ||
Livewire::test(ListChannels::class) | ||
->assertCanSeeTableRecords($channels); | ||
}); | ||
|
||
it('Admin user can create channel', function (): void { | ||
Livewire::test(ListChannels::class) | ||
->callAction(CreateAction::class, data: [ | ||
'name' => $name = 'my channel', | ||
'color' => '#FFFFFF', | ||
]) | ||
->assertHasNoActionErrors() | ||
->assertStatus(200); | ||
|
||
$channel = Channel::first(); | ||
|
||
expect($channel) | ||
->toBeInstanceOf(Channel::class) | ||
->and($channel->name)->toBe($name); | ||
}); | ||
|
||
it('Admin user can edit channel', function (): void { | ||
$channel = Channel::factory()->create(); | ||
|
||
Livewire::test(ListChannels::class) | ||
->callTableAction(EditAction::class, $channel, data: [ | ||
'name' => 'Edited channel', | ||
]) | ||
->assertHasNoTableActionErrors(); | ||
|
||
$channel->refresh(); | ||
|
||
expect($channel->name) | ||
->toBe('Edited channel'); | ||
}); | ||
|
||
})->group('channels'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.