38 lines
660 B
PHP
38 lines
660 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Post extends Model
|
|
{
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'user_id', 'title', 'thumb', 'content', 'published_at', 'category_id'
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\User');
|
|
}
|
|
|
|
public function comments()
|
|
{
|
|
return $this->hasMany('App\Comment');
|
|
}
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo('App\Category');
|
|
}
|
|
|
|
public function pictures()
|
|
{
|
|
return $this->hasMany('App\Picture');
|
|
}
|
|
}
|