-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
16 changed files
with
296 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\ServiceResource\Pages; | ||
use App\Models\Service; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Table; | ||
|
||
class ServiceResource extends Resource | ||
{ | ||
protected static ?string $model = Service::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
public static function getNavigationGroup(): ?string | ||
{ | ||
return __('navigation.configurations._group'); | ||
} | ||
|
||
public static function getNavigationLabel(): string | ||
{ | ||
return __('navigation.configurations.services'); | ||
} | ||
|
||
public static function getModelLabel(): string | ||
{ | ||
return __('service.label.singular'); | ||
} | ||
|
||
public static function getPluralModelLabel(): string | ||
{ | ||
return __('service.label.plural'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
// | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('name') | ||
->label(__('service.field.name')) | ||
->searchable(), | ||
|
||
TextColumn::make('interventions_count') | ||
->counts('interventions'), | ||
|
||
]) | ||
->actions([ | ||
Tables\Actions\ViewAction::make(), | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make() | ||
->visible(fn (Service $record) => ! $record->interventions_count), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ManageServices::route('/'), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/ServiceResource/Pages/ManageServices.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 App\Filament\Resources\ServiceResource\Pages; | ||
|
||
use App\Filament\Resources\ServiceResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ManageRecords; | ||
|
||
class ManageServices extends ManageRecords | ||
{ | ||
protected static string $resource = ServiceResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Models; | ||
|
||
use App\Concerns\BelongsToOrganization; | ||
use Illuminate\Database\Eloquent\Concerns\HasUlids; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
class Intervention extends Model | ||
{ | ||
use BelongsToOrganization; | ||
use HasFactory; | ||
use HasUlids; | ||
|
||
public $with = ['service']; | ||
|
||
public function service(): BelongsTo | ||
{ | ||
return $this->belongsTo(Service::class); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Models; | ||
|
||
use App\Concerns\BelongsToOrganization; | ||
use Illuminate\Database\Eloquent\Concerns\HasUlids; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
|
||
class Service extends Model | ||
{ | ||
use BelongsToOrganization; | ||
use HasFactory; | ||
use HasUlids; | ||
|
||
public function interventions(): HasMany | ||
{ | ||
return $this->hasMany(Intervention::class); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Intervention> | ||
*/ | ||
class InterventionFactory extends Factory | ||
{ | ||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function definition(): array | ||
{ | ||
return [ | ||
'name' => fake()->name(), | ||
'description' => fake()->paragraph(), | ||
]; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Database\Factories; | ||
|
||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
/** | ||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Service> | ||
*/ | ||
class ServiceFactory extends Factory | ||
{ | ||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function definition(): array | ||
{ | ||
return [ | ||
'name' => fake()->name(), | ||
'description' => fake()->paragraph(), | ||
]; | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
database/migrations/2023_11_28_124405_create_services_table.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,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Models\Organization; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('services', function (Blueprint $table) { | ||
$table->ulid('id')->primary(); | ||
$table->timestamps(); | ||
$table->string('name'); | ||
$table->text('description')->nullable(); | ||
$table->foreignIdFor(Organization::class)->constrained()->cascadeOnDelete(); | ||
}); | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
database/migrations/2023_11_28_131713_create_interventions_table.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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use App\Models\Organization; | ||
use App\Models\Service; | ||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('interventions', function (Blueprint $table) { | ||
$table->ulid('id')->primary(); | ||
$table->timestamps(); | ||
$table->string('name'); | ||
$table->text('description')->nullable(); | ||
$table->foreignIdFor(Service::class)->constrained()->cascadeOnDelete(); | ||
$table->foreignIdFor(Organization::class)->constrained()->cascadeOnDelete(); | ||
}); | ||
} | ||
}; |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
|
||
'label' => [ | ||
'singular' => 'intervenție', | ||
'plural' => 'Intervenții', | ||
], | ||
|
||
'field' => [ | ||
'name' => 'Numele intervenției', | ||
'description' => 'Descrierea intervenției', | ||
], | ||
]; |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
return [ | ||
|
||
'label' => [ | ||
'singular' => 'serviciu', | ||
'plural' => 'Servicii', | ||
], | ||
|
||
'field' => [ | ||
'name' => 'Numele serviciului', | ||
'description' => 'Descrierea serviciului', | ||
], | ||
]; |