Add CatalogPlugin scaffold and EvCompany resource (T2.0, T2.1)

Registers CatalogPlugin with the admin panel so catalog Filament
resources auto-discover, and adds the EvCompany model/migration/
factory plus its Filament resource (auto-generated slug on create).
This commit is contained in:
Nyan Lin Paing
2026-08-05 22:43:34 +07:00
parent 17dd5acd23
commit 6039d25c6d
15 changed files with 422 additions and 1 deletions
@@ -0,0 +1,59 @@
<?php
namespace Modules\Catalog\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Modules\Catalog\Database\Factories\EvCompanyFactory;
class EvCompany extends Model
{
/** @use HasFactory<EvCompanyFactory> */
use HasFactory;
/**
* @var list<string>
*/
protected $fillable = [
'name',
'mm_name',
'slug',
'description',
'mm_description',
'contact',
'address',
'logo',
'is_active',
];
protected static function booted(): void
{
static::creating(function (self $evCompany): void {
if (filled($evCompany->slug)) {
return;
}
$slug = Str::slug($evCompany->name);
$uniqueSlug = $slug;
$suffix = 1;
while (static::where('slug', $uniqueSlug)->exists()) {
$uniqueSlug = "{$slug}-{$suffix}";
$suffix++;
}
$evCompany->slug = $uniqueSlug;
});
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_active' => 'boolean',
];
}
}