Action.php
3.8 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* +-----------------------------------------------------------------------------------------------------------------------
* 重写 laravel-admin Actions\Action 类
* +-----------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Admin\Rewrite\Actions
* @package App\Admin\Rewrite\Actions
* @author Richer <yangzi1028@163.com>
* @date 2020年11月12日13:49:31
* @copyright 2020-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
namespace App\Admin\Rewrite\Actions;
use Encore\Admin\Actions\Action as EncoreAction;
use Encore\Admin\Admin;
/**
* @method $this success($title, $text = '', $options = [])
* @method $this error($title, $text = '', $options = [])
* @method $this warning($title, $text = '', $options = [])
* @method $this info($title, $text = '', $options = [])
* @method $this question($title, $text = '', $options = [])
* @method $this confirm($title, $text = '', $options = [])
* @method Field\Text text($column, $label = '')
* @method Field\Number number($column, $label = '')
* @method Field\Display display($column, $label = '')
* @method Field\Email email($column, $label = '')
* @method Field\Integer integer($column, $label = '')
* @method Field\Ip ip($column, $label = '')
* @method Field\Url url($column, $label = '')
* @method Field\Password password($column, $label = '')
* @method Field\Mobile mobile($column, $label = '')
* @method Field\Textarea textarea($column, $label = '')
* @method Field\Select select($column, $label = '')
* @method Field\MultipleSelect multipleSelect($column, $label = '')
* @method Field\Checkbox checkbox($column, $label = '')
* @method Field\Radio radio($column, $label = '')
* @method Field\File file($column, $label = '')
* @method Field\Image image($column, $label = '')
* @method Field\MultipleFile multipleFile($column, $label = '')
* @method Field\MultipleImage multipleImage($column, $label = '')
* @method Field\Date date($column, $label = '')
* @method Field\Datetime datetime($column, $label = '')
* @method Field\Time time($column, $label = '')
* @method Field\Hidden hidden($column, $label = '')
* @method $this modalLarge()
* @method $this modalSmall()
*/
abstract class Action extends EncoreAction
{
use Authorizable;
/**
* @throws \Exception
*/
protected function initInteractor()
{
if ($hasForm = method_exists($this, 'form')) {
$this->interactor = new Interactor\Form($this);
}
if ($hasDialog = method_exists($this, 'dialog')) {
$this->interactor = new Interactor\Dialog($this);
}
if ($hasForm && $hasDialog) {
throw new \Exception('Can only define one of the methods in `form` and `dialog`');
}
}
/**
* @param string $html
* @return string
*/
public function html($html = '')
{
$field = view('admin::partials.html', ['html' => [$html]]);
$this->interactor->addHtml($field);
}
/**
* @param string $method
* @param array $arguments
*
* @throws \Exception
*
* @return mixed
*/
public function __call($method, $arguments = [])
{
if (in_array($method, Interactor\Interactor::$elements)) {
return $this->interactor->{$method}(...$arguments);
}
throw new \BadMethodCallException("Method {$method} does not exist.");
}
}