-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filament): added video-script relationship (#667)
- Loading branch information
Showing
12 changed files
with
314 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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 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
117 changes: 117 additions & 0 deletions
117
app/Filament/Resources/Wiki/Video/RelationManagers/ScriptVideoRelationManager.php
This file contains 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,117 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\Wiki\Video\RelationManagers; | ||
|
||
use App\Filament\Resources\BaseRelationManager; | ||
use App\Filament\Resources\Wiki\Video\Script as ScriptResource; | ||
use App\Models\Wiki\Video; | ||
use App\Models\Wiki\Video\VideoScript; | ||
use Filament\Forms\Form; | ||
use Filament\Tables\Table; | ||
|
||
/** | ||
* Class ScriptVideoRelationManager. | ||
*/ | ||
class ScriptVideoRelationManager extends BaseRelationManager | ||
{ | ||
/** | ||
* The relationship the relation manager corresponds to. | ||
* | ||
* @return string | ||
*/ | ||
protected static string $relationship = Video::RELATION_SCRIPT; | ||
|
||
/** | ||
* The form to the actions. | ||
* | ||
* @param Form $form | ||
* @return Form | ||
* | ||
* @noinspection PhpMissingParentCallCommonInspection | ||
*/ | ||
public function form(Form $form): Form | ||
{ | ||
return ScriptResource::form($form); | ||
} | ||
|
||
/** | ||
* The index page of the resource. | ||
* | ||
* @param Table $table | ||
* @return Table | ||
* | ||
* @noinspection PhpMissingParentCallCommonInspection | ||
*/ | ||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->heading(ScriptResource::getLabel()) | ||
->modelLabel(ScriptResource::getLabel()) | ||
->recordTitleAttribute(VideoScript::ATTRIBUTE_PATH) | ||
->inverseRelationship(VideoScript::RELATION_VIDEO) | ||
->columns(ScriptResource::table($table)->getColumns()) | ||
->filters(static::getFilters()) | ||
->headerActions(static::getHeaderActions()) | ||
->actions(static::getActions()) | ||
->bulkActions(static::getBulkActions()); | ||
} | ||
|
||
/** | ||
* Get the filters available for the relation. | ||
* | ||
* @return array | ||
* | ||
* @noinspection PhpMissingParentCallCommonInspection | ||
*/ | ||
public static function getFilters(): array | ||
{ | ||
return array_merge( | ||
parent::getFilters(), | ||
[], | ||
); | ||
} | ||
|
||
/** | ||
* Get the actions available for the relation. | ||
* | ||
* @return array | ||
* | ||
* @noinspection PhpMissingParentCallCommonInspection | ||
*/ | ||
public static function getActions(): array | ||
{ | ||
return array_merge( | ||
parent::getActions(), | ||
[], | ||
); | ||
} | ||
|
||
/** | ||
* Get the bulk actions available for the relation. | ||
* | ||
* @return array | ||
* | ||
* @noinspection PhpMissingParentCallCommonInspection | ||
*/ | ||
public static function getBulkActions(): array | ||
{ | ||
return array_merge( | ||
parent::getBulkActions(), | ||
[], | ||
); | ||
} | ||
|
||
/** | ||
* Get the header actions available for the relation. | ||
* | ||
* @return array | ||
* | ||
* @noinspection PhpMissingParentCallCommonInspection | ||
*/ | ||
public static function getHeaderActions(): array | ||
{ | ||
return ScriptResource::getHeaderActions(); | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.