refactor(models): replace HasFactory with HasContainerFactory across all models
Add static $factory property for Porto-style model factory resolution
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
namespace App\Containers\Article\Models;
|
||||
|
||||
use App\Ship\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Ship\Traits\HasContainerFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasContainerFactory;
|
||||
|
||||
protected static string $factory = \Database\Factories\CategoryFactory::class;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Containers\Article\Enums\PostStatus;
|
||||
use App\Containers\User\Models\User;
|
||||
use App\Containers\Widget\Models\Slide;
|
||||
use App\Ship\Traits\HasSeo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Ship\Traits\HasContainerFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
@@ -14,7 +14,9 @@ use Spatie\Tags\HasTags;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
use HasFactory, HasTags, HasSeo;
|
||||
use HasContainerFactory, HasTags, HasSeo;
|
||||
|
||||
protected static string $factory = \Database\Factories\PostFactory::class;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
|
||||
@@ -3,9 +3,16 @@
|
||||
namespace App\Containers\Article\Models;
|
||||
|
||||
use App\Ship\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Ship\Traits\HasContainerFactory;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasContainerFactory;
|
||||
|
||||
protected static string $factory = \Database\Factories\TagFactory::class;
|
||||
|
||||
protected $casts = [
|
||||
'name' => 'array',
|
||||
'slug' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user