25 lines
476 B
PHP
25 lines
476 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class PostCategory extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'post_categories';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public function posts()
|
|
{
|
|
return $this->hasMany(Post::class, 'id', 'post_id');
|
|
}
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(Category::class, 'category_id', 'id');
|
|
}
|
|
}
|