InvoiceAction.php
2.5 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
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
* 自定义Action:渲染生成 Invoice Action
+-----------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Admin\Extensions\Actions
* @package App\Admin\Extensions\Actions
* @author Richer <yangzi1028@163.com>
* @date 2022年7月26日17:36:40
* @copyright 2021-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
namespace App\Admin\Extensions\Actions;
use App\Admin\Rewrite\Actions\RowAction;
use App\Admin\Traits\FormFieldTrait;
use App\Models\Invoice\Invoice;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
class InvoiceAction extends RowAction
{
use FormFieldTrait;
// public $name = '<i class="fa fa-check-square-o"></i>开票';
public $name = '确认开票';
protected $style = 'btn btn-success';
protected $selector = '.grid-invoice';
public function handle(Model $model)
{
// dump(request()->all());
// 自定义上传文件
$images = $this->formUpload(request(), $model);
if (!$images) {
return $this->response()->error(__('operate_failed'))->refresh();
}
$image = Arr::get($images, 'full_path');
$original_name = Arr::get($images, 'original_name');
$model->image = $image;
$model->image_name = $original_name;
$model->status = Invoice::INVOICED;
$result = $model->save();
if ($result) {
return $this->response()->success(__('operate_succeeded'))->refresh();
} else {
return $this->response()->error(__('operate_failed'))->refresh();
}
}
public function form()
{
// 上传文件
$this->image('image', __('invoice_image'))
->removable()
->uniqueName()
->required()
->move('/admin/invoice/'.date('Ymd'));
// $type = [
// 1 => '广告',
// 2 => '违法',
// 3 => '钓鱼',
// ];
//
//
// $this->image('name', 'Placeholder...');
//
// $this->checkbox('type', '类型')->options($type);
// $this->textarea('reason', '原因')->rules('required');
}
public function html($html = '')
{
return "<a class='report-posts btn btn-sm btn-danger'><i class='fa fa-info-circle'></i>举报</a>";
}
}