PHP code example of ozankurt / laravel-modules-core
1. Go to this page and download the library: Download ozankurt/laravel-modules-core library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Illuminate\Console\Command;
use Kurt\Modules\Core\Concerns\AbortsInProduction;
class SeedDemoCommand extends Command
{
use AbortsInProduction;
protected $signature = 'blog:demo {--force}';
public function handle(): int
{
if ($this->abortIfProduction()) {
return self::FAILURE;
}
// ... seed demo data ...
return self::SUCCESS;
}
}
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
use Kurt\Modules\Core\Concerns\HasEnumLabels;
enum Status: string implements HasColor, HasLabel
{
use HasEnumLabels;
case Draft = 'draft';
case InReview = 'in_review'; // getLabel() => "In Review"
case Published = 'published';
// Optional: override getColor() per case; getLabel() keeps the default.
public function getColor(): string|array|null
{
return match ($this) {
self::Published => 'success',
default => null,
};
}
}
// Single: pass the resource itself — nested resources are not re-wrapped.
return $this->respond(PostResource::make($post));
// Collection: map through the resource, then envelope.
return $this->respondPaginated($paginator, PostResource::class);