| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use app\common\model\PaymentChannelModel;
- use think\App;
- use think\facade\View;
- use think\Request;
- class PaymentChannel extends BaseController
- {
- private $model;
- public function __construct(App $app)
- {
- $this->model = new PaymentChannelModel();
- parent::__construct($app);
- }
- public function index() {
- View::assign("list",$this->model->findAll());
- return view();
- }
- public function add() {
- if ($this->request->isAjax()) {
- $params = $this->request->param();
- $this->model->save([
- 'name' => $params['name'],
- 'icon' => $params['icon'],
- ]);
- return $this->ok(true);
- }
- return view();
- }
- public function delete(Request $request) {
- $params = $request->param();
- if(!isset($params['ids']))
- return $this->fail(lang("Please select the data you want to delete"));
- $this->model->deleteByIds(explode(',',$params['ids']));
- return $this->ok(true);
- }
- public function edit() {
- $params = $this->request->param();
- if(!isset($params['id']))
- return $this->fail(lang('ID not exist'));
- $channel = $this->model->findById($params['id']);
- if($this->request->isAjax()) {
- $res = $this->model->where('id',$params['id'])->update([
- 'icon' => $params['icon'],
- 'name' => $params['name'],
- 'update_time' => time()
- ]);
- return $this->ok($res);
- }
- View::assign('channel', $channel);
- return view();
- }
- /**
- * @return \think\response\Json
- */
- public function upload() {
- // 获取表单上传文件 例如上传了001.jpg
- $file = request()->file('file');
- // 上传到本地服务器
- $save_name = \think\facade\Filesystem::disk('public')->putFile( 'icon', $file);
- return $this->ok(str_replace('\\',"/",'/storage/'.$save_name));
- }
- }
|