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
13 changed files
with
245 additions
and
20 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
database/migrations/create_admin_kit_vacancy_gallery_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,29 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
use AdminKit\Vacancy\Models\Vacancy; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('admin_kit_vacancy_gallery', function (Blueprint $table) { | ||
$table->id(); | ||
|
||
// add fields | ||
$table->foreignId('vacancy_id') | ||
->constrained('admin_kit_vacancy') | ||
->cascadeOnDelete(); | ||
$table->jsonb('title'); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('admin_kit_vacancy_gallerys'); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace AdminKit\Vacancy\Models; | ||
|
||
use Spatie\MediaLibrary\HasMedia; | ||
use Spatie\MediaLibrary\InteractsWithMedia; | ||
use AdminKit\Core\Abstracts\Models\AbstractModel; | ||
use AdminKit\Vacancy\Database\Factories\VacancyFactory; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Spatie\Translatable\HasTranslations; | ||
|
||
class VacancyGallery extends AbstractModel implements HasMedia | ||
{ | ||
use HasFactory; | ||
use HasTranslations; | ||
use InteractsWithMedia; | ||
|
||
protected $table = 'admin_kit_vacancy_gallery'; | ||
|
||
protected $fillable = [ | ||
'title', | ||
]; | ||
|
||
protected $casts = [ | ||
// | ||
]; | ||
|
||
protected $translatable = [ | ||
'title', | ||
]; | ||
|
||
protected static function newFactory(): VacancyFactory | ||
{ | ||
return new VacancyFactory(); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace AdminKit\Vacancy\UI\API\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class VacancyGalleryResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
'title' => $this->title, | ||
'background' => $this->getFirstMediaUrl('gallery'), | ||
]; | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace AdminKit\Vacancy\UI\API\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class VacancyResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
'title' => $this->title, | ||
'subtitle' => $this->subtitle, | ||
'background' => $this->getFirstMediaUrl('main'), | ||
'action' => [ | ||
'title' => $this->action_title, | ||
'link' => $this->action_link, | ||
], | ||
'gallery' => VacancyGalleryResource::collection($this->gallery), | ||
]; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
|
||
use AdminKit\Vacancy\UI\API\Controllers\VacancyController; | ||
use Illuminate\Support\Facades\Route; | ||
use AdminKit\Vacancy\UI\API\Controllers\VacancyController; | ||
|
||
Route::get('/vacancy', [VacancyController::class, 'index']); | ||
Route::get('/vacancy/{id}', [VacancyController::class, 'show']); | ||
Route::get('/vacancy', [VacancyController::class, 'showFirst']); |
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
62 changes: 62 additions & 0 deletions
62
src/UI/Filament/Resources/VacancyResource/RelationManagers/VacancyGalleryRelationManager.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,62 @@ | ||
<?php | ||
|
||
namespace AdminKit\Vacancy\UI\Filament\Resources\VacancyResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Tables; | ||
use Filament\Forms\Form; | ||
use Filament\Tables\Table; | ||
use Filament\Forms\Components\Tabs\Tab; | ||
use AdminKit\Core\Forms\Components\TranslatableTabs; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
|
||
class VacancyGalleryRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'gallery'; | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\SpatieMediaLibraryFileUpload::make('background') | ||
->label(__('admin-kit-vacancy::vacancy.resource.image')) | ||
->collection('gallery') | ||
->image() | ||
->columnSpan(2) | ||
->required(), | ||
TranslatableTabs::make(fn ($locale) => Tab::make($locale)->schema([ | ||
Forms\Components\TextInput::make('title.'.$locale) | ||
->label(__('admin-kit-vacancy::vacancy.resource.title')) | ||
->required(), | ||
]))->columnSpan(2), | ||
]); | ||
} | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->recordTitleAttribute('title') | ||
->columns([ | ||
Tables\Columns\SpatieMediaLibraryImageColumn::make('background') | ||
->collection('gallery') | ||
->label(__('admin-kit-vacancy::vacancy.resource.image')), | ||
Tables\Columns\TextColumn::make('title') | ||
->label(__('admin-kit-vacancy::vacancy.resource.title')), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\CreateAction::make(), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
} |
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