1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Modules\Admin\Controllers\Admin;
- use App\Base\BaseController;
- use App\Models\Setting;
- use App\Modules\Admin\Services\SettingService;
- use Illuminate\Support\Arr;
- class BannerController extends BaseController
- {
- /** @var SettingService $service */
- protected $service;
- public function __construct(SettingService $authService)
- {
- $this->service = $authService;
- }
- public function paginate()
- {
- $data = $this->valid([
- "name" => "",
- "status" => "",
- "page_size" => "",
- ]);
- return $this->ok($this->service->bannerPaginate($data));
- }
- public function store()
- {
- $params = $this->valid([
- "id" => "",
- "name" => "required",
- "imageUrl" => "required|url",
- "sort" => "required|int",
- "interval" => "",
- ]);
- return $this->ok($this->service->store($params));
- }
- public function del()
- {
- $id = request()->input("id", 0);
- Setting::whereType(Setting::TYPE_BANNER)->where("id", $id)->delete();
- return $this->ok(true);
- }
- public function changeStatus()
- {
- $id = request()->input("id", 0);
- $m = Setting::whereType(Setting::TYPE_BANNER)->where("id", $id)->firstOrFail();
- $value = $m->value ?? [];
- $isUse = 1;
- if (Arr::get($value, "is_use")) {
- $isUse = 0;
- }
- $value['is_use'] = $isUse;
- $m->value = $value;
- $m->save();
- return $this->ok(true);
- }
- }
|