5 changed files with 177 additions and 7 deletions
-
75app/Admin/Actions/Tree/CategoryTie.php
-
23app/Admin/Controllers/v3/CategoryController.php
-
10app/Admin/Controllers/v3/StoreController.php
-
74app/Admin/Forms/CategoryTieForm.php
-
2app/Admin/routes.php
@ -0,0 +1,75 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Tree; |
||||
|
|
||||
|
use Dcat\Admin\Actions\Response; |
||||
|
use Dcat\Admin\Form; |
||||
|
use Dcat\Admin\Traits\HasPermissions; |
||||
|
use Dcat\Admin\Tree\AbstractTool; |
||||
|
use Illuminate\Contracts\Auth\Authenticatable; |
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
use Illuminate\Http\Request; |
||||
|
use App\Models\v3\Category as CategoryModel; |
||||
|
|
||||
|
class CategoryTie extends AbstractTool |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '绑定分类到首页'; |
||||
|
|
||||
|
/** |
||||
|
* Handle the action request. |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
return $this->response() |
||||
|
->success('Processed successfully.') |
||||
|
->redirect('/category'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|void |
||||
|
*/ |
||||
|
public function href() |
||||
|
{ |
||||
|
// return admin_url('category/tie');
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|array|void |
||||
|
*/ |
||||
|
public function confirm() |
||||
|
{ |
||||
|
// return ['Confirm?', 'contents'];
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加JS |
||||
|
* |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected function script() |
||||
|
{ |
||||
|
return <<<JS |
||||
|
$('.category-tie-row').on('click', function () { |
||||
|
// Your code.
|
||||
|
window.location.href ='/admin/category/tie'; |
||||
|
}); |
||||
|
JS; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param Model|Authenticatable|HasPermissions|null $user |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
protected function authorize($user): bool |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Forms; |
||||
|
|
||||
|
use Dcat\Admin\Widgets\Form; |
||||
|
use Symfony\Component\HttpFoundation\Response; |
||||
|
use App\Libs\SsdbClient; |
||||
|
|
||||
|
class CategoryTieForm extends Form |
||||
|
{ |
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
protected $ssdb; |
||||
|
|
||||
|
/** |
||||
|
* Handle the form request. |
||||
|
* |
||||
|
* @param array $input |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(array $input) |
||||
|
{ |
||||
|
|
||||
|
$data = [ |
||||
|
'activity' => $input['activity'], |
||||
|
'forward' => $input['forward'], |
||||
|
'repay' => $input['repay'], |
||||
|
]; |
||||
|
|
||||
|
$coupon = $this->ssdb->client()->multi_hset('coupon_rebate_activity',$data); |
||||
|
if($coupon === false){ |
||||
|
return $this->error('修改失败'); |
||||
|
} |
||||
|
|
||||
|
return $this->success('修改成功', '/couponTie'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Build a form here. |
||||
|
*/ |
||||
|
public function form() |
||||
|
{ |
||||
|
// $this->ssdb = new SsdbClient();
|
||||
|
// $coupon = $this->ssdb->client()->hgetall('coupon_rebate_activity');
|
||||
|
// if(empty($coupon)){
|
||||
|
// $coupon = [
|
||||
|
// 'activity'=> 0,
|
||||
|
// 'forward'=> '',
|
||||
|
// 'repay' => ''
|
||||
|
// ];
|
||||
|
// }
|
||||
|
|
||||
|
$this->text('id')->required(); |
||||
|
$this->image('cover_img')->required(); |
||||
|
$this->text('title')->required(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* The data of the form. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function default() |
||||
|
{ |
||||
|
return [ |
||||
|
'activity' => '2', |
||||
|
'forward' => '', |
||||
|
'repay' => '', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue