feat: add save feature

This commit is contained in:
2026-05-23 01:09:29 +03:30
parent e314f95656
commit 8339a03168
8 changed files with 401 additions and 13 deletions
+12 -8
View File
@@ -5,9 +5,11 @@
use Illuminate\Database\Eloquent\Model;
use App\Traits\HasRatings;
use App\Traits\HasComments;
use App\Traits\HasSaves;
class Media extends Model
{
use HasRatings, HasComments;
use HasRatings, HasComments,HasSaves;
protected $fillable = [
'user_id',
'image_id',
@@ -21,16 +23,18 @@ class Media extends Model
'visibility',
'is_premium'
];
protected $appends = [
'average_rating',
protected $appends = [
'average_rating',
'user_rating',
'ratings_count',
'comments_count',
'has_user_commented', // Add this
'user_comment', // Add this
'user_comment_id', // Add this
'has_user_rated' // Add this
];
'has_user_commented',
'user_comment',
'user_comment_id',
'has_user_rated',
'is_saved',
'saved_count'
];
public function image()
{
return $this->belongsTo(Image::class);