generated from IBEC-BOX/admin-kit-package-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
294 additions
and
10 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
database/migrations/add_category_id_column_to_admin_kit_documents_table.php.stub
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,22 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::table('admin_kit_documents', function (Blueprint $table) { | ||
$table->unsignedBigInteger('category_id')->nullable(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::table('admin_kit_documents', function (Blueprint $table) { | ||
$table->dropColumn('category_id'); | ||
}); | ||
} | ||
}; |
25 changes: 25 additions & 0 deletions
25
database/migrations/create_admin_kit_document_categories_table.php.stub
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,25 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('admin_kit_document_categories', function (Blueprint $table) { | ||
$table->id(); | ||
|
||
$table->json('title')->default('{}'); | ||
$table->integer('sort')->nullable(); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('admin_kit_document_categories'); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace AdminKit\Documents\Models; | ||
|
||
use AdminKit\Core\Abstracts\Models\AbstractModel; | ||
use Spatie\Translatable\HasTranslations; | ||
|
||
class DocumentCategory extends AbstractModel | ||
{ | ||
use HasTranslations; | ||
|
||
protected $table = 'admin_kit_document_categories'; | ||
|
||
protected $fillable = [ | ||
'title', | ||
]; | ||
|
||
protected $translatable = [ | ||
'title', | ||
]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace AdminKit\Documents\UI\Filament\Resources; | ||
|
||
use AdminKit\Core\Forms\Components\TranslatableTabs; | ||
use AdminKit\Documents\Models\DocumentCategory; | ||
use AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource\Pages; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
|
||
class DocumentCategoryResource extends Resource | ||
{ | ||
protected static ?string $model = DocumentCategory::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
public static function getModelLabel(): string | ||
{ | ||
return 'Категория документов'; | ||
} | ||
|
||
public static function getPluralModelLabel(): string | ||
{ | ||
return 'Категории документов'; | ||
} | ||
|
||
public static function getNavigationGroup(): ?string | ||
{ | ||
return 'Документы'; | ||
} | ||
|
||
public static function getTitleCaseModelLabel(): string | ||
{ | ||
return self::getModelLabel(); | ||
} | ||
|
||
public static function getTitleCasePluralModelLabel(): string | ||
{ | ||
return self::getPluralModelLabel(); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TranslatableTabs::make(fn ($locale) => [ | ||
TextInput::make("title.$locale") | ||
->label('Наименование') | ||
->required($locale === app()->getLocale()), | ||
]) | ||
->columnSpan(2), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('title') | ||
->label('Наименование') | ||
->limit(30), | ||
Tables\Columns\TextColumn::make('sort') | ||
->label('Порядок'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]) | ||
->reorderable('sort') | ||
->defaultSort('sort'); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListDocumentCategory::route('/'), | ||
'create' => Pages\CreateDocumentCategory::route('/create'), | ||
'edit' => Pages\EditDocumentCategory::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/UI/Filament/Resources/DocumentCategoryResource/Pages/CreateDocumentCategory.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,11 @@ | ||
<?php | ||
|
||
namespace AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource\Pages; | ||
|
||
use AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateDocumentCategory extends CreateRecord | ||
{ | ||
protected static string $resource = DocumentCategoryResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/UI/Filament/Resources/DocumentCategoryResource/Pages/EditDocumentCategory.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,19 @@ | ||
<?php | ||
|
||
namespace AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource\Pages; | ||
|
||
use AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditDocumentCategory extends EditRecord | ||
{ | ||
protected static string $resource = DocumentCategoryResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/UI/Filament/Resources/DocumentCategoryResource/Pages/ListDocumentCategory.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,19 @@ | ||
<?php | ||
|
||
namespace AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource\Pages; | ||
|
||
use AdminKit\Documents\UI\Filament\Resources\DocumentCategoryResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListDocumentCategory extends ListRecords | ||
{ | ||
protected static string $resource = DocumentCategoryResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
Oops, something went wrong.