forked from basic-app/crud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrudTrait.php
59 lines (52 loc) · 2 KB
/
CrudTrait.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
<?php
/**
* @author Basic App Dev Team
* @license MIT
* @link http://basic-app.com
*/
namespace BasicApp\Crud;
trait CrudTrait
{
public function index()
{
return $this->createCrudAction(IndexAction::class, [
'view' => $this->indexTemplate ?? 'index',
'searchModelClass' => $this->searchModelClass ?? null,
'perPage' => $this->perPage ?? null,
'orderBy' => $this->orderBy ?? null,
'parentKey' => $this->parentKey ?? null,
'beforeFind' => $this->beforeFind ?? null
])->run();
}
public function create()
{
return $this->createCrudAction(CreateAction::class, [
'view' => 'create',
'searchModelClass' => property_exists($this, 'searchModelClass') ? $this->searchModelClass : null,
'parentKey' => property_exists($this, 'parentKey') ? $this->parentKey : null
])->run();
}
public function update()
{
return $this->createCrudAction(UpdateAction::class, [
'view' => 'update',
'searchModelClass' => property_exists($this, 'searchModelClass') ? $this->searchModelClass : null,
'parentKey' => property_exists($this, 'parentKey') ? $this->parentKey : null
])->run();
}
public function view()
{
return $this->createCrudAction(ViewAction::class, [
'view' => 'view',
'searchModelClass' => property_exists($this, 'searchModelClass') ? $this->searchModelClass : null,
'parentKey' => property_exists($this, 'parentKey') ? $this->parentKey : null
])->run();
}
public function delete()
{
return $this->createCrudAction(DeleteAction::class, [
'searchModelClass' => property_exists($this, 'searchModelClass') ? $this->searchModelClass : null,
'parentKey' => property_exists($this, 'parentKey') ? $this->parentKey : null
])->run();
}
}