-
Notifications
You must be signed in to change notification settings - Fork 14
/
Post.php
77 lines (63 loc) · 1.89 KB
/
Post.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace Modules\MyBlog\Models;
use App\Abstracts\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Post extends Model
{
use HasFactory;
protected $table = 'my_blog_posts';
protected $fillable = ['company_id', 'name', 'description', 'category_id', 'enabled', 'created_from', 'created_by'];
/**
* Sortable columns.
*
* @var array
*/
public $sortable = ['name', 'category.name', 'description', 'enabled'];
public function category()
{
return $this->belongsTo('App\Models\Setting\Category')->withDefault(['name' => trans('general.na')]);
}
public function comments()
{
return $this->hasMany('Modules\MyBlog\Models\Comment');
}
/**
* Get the line actions.
*
* @return array
*/
public function getLineActionsAttribute()
{
$actions = [];
$actions[] = [
'title' => trans('general.edit'),
'icon' => 'edit',
'url' => route('my-blog.posts.edit', $this->id),
'permission' => 'update-my-blog-posts',
];
$actions[] = [
'title' => trans('general.duplicate'),
'icon' => 'file_copy',
'url' => route('my-blog.posts.duplicate', $this->id),
'permission' => 'create-my-blog-posts',
];
$actions[] = [
'type' => 'delete',
'title' => trans_choice('my-blog::general.posts', 1),
'icon' => 'delete',
'route' => 'my-blog.posts.destroy',
'permission' => 'delete-my-blog-posts',
'model' => $this,
];
return $actions;
}
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \Modules\MyBlog\Database\Factories\Post::new();
}
}