feat(category): add banner functionality to categories with related resource and migration tests
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Domains\Commerce\Catalog\Models;
|
||||
|
||||
use App\Domains\Core\Auth\Models\User;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Shared\Attachable\Models\Attachment;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -16,6 +17,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
'categoria_id',
|
||||
'nombre',
|
||||
'is_enabled',
|
||||
'banner_id',
|
||||
'banner_enabled',
|
||||
])]
|
||||
class Category extends Model
|
||||
{
|
||||
@@ -25,6 +28,7 @@ class Category extends Model
|
||||
|
||||
protected $attributes = [
|
||||
'is_enabled' => true,
|
||||
'banner_enabled' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -35,6 +39,8 @@ class Category extends Model
|
||||
return [
|
||||
'categoria_id' => 'integer',
|
||||
'is_enabled' => 'boolean',
|
||||
'banner_id' => 'integer',
|
||||
'banner_enabled' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -59,6 +65,12 @@ class Category extends Model
|
||||
return $this->belongsTo(self::class, 'categoria_id');
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Attachment, $this> */
|
||||
public function banner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Attachment::class, 'banner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Category, $this>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user