feat: add Music Productions module with CRUD resources and frontend views
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\HasTranslations;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class MusicProduction extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, HasTranslations;
|
||||
|
||||
protected $table = 'music_productions';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'slug',
|
||||
'cover_image',
|
||||
'content',
|
||||
'client_name',
|
||||
'production_date',
|
||||
'gallery',
|
||||
'is_active',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
/**
|
||||
* Translatable fields
|
||||
*/
|
||||
protected $translatable = [
|
||||
'title',
|
||||
'content',
|
||||
'client_name',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'production_date' => 'date',
|
||||
'gallery' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
|
||||
public function getUrlAttribute()
|
||||
{
|
||||
return route('music-productions.show', $this->slug);
|
||||
}
|
||||
|
||||
public function getCoverImageUrlAttribute()
|
||||
{
|
||||
if ($this->cover_image) {
|
||||
return asset('storage/' . $this->cover_image);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
public function scopeOrdered($query)
|
||||
{
|
||||
return $query->orderBy('sort_order', 'asc')->orderBy('production_date', 'desc');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user