TA/web_JMW/app/Models/Favorite.php

33 lines
591 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Favorite extends Model
{
use HasFactory;
protected $fillable = [
'username',
'category_id',
];
/**
* Relationship with User model
*/
public function user()
{
return $this->belongsTo(User::class, 'username', 'username');
}
/**
* Relationship with Category model
*/
public function category()
{
return $this->belongsTo(Category::class, 'category_id', 'id');
}
}