12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace App\Modules\Admin\Controllers\Admin;
- use App\Base\BaseController;
- use App\Models\Auth\AdminGroup;
- use App\Models\Auth\AdminPermission;
- use App\Models\Goods\Category;
- use App\Models\Goods\Spec;
- use App\Modules\Admin\Services\SettingService;
- class CommonController extends BaseController
- {
- public function groupMap()
- {
- $group = AdminGroup::all();
- return $this->ok([
- "list" => $group->map(function (AdminGroup $m) {
- return [
- "id" => $m->id,
- "name" => $m->name,
- ];
- }),
- ]);
- }
- public function permissionMap()
- {
- $all = AdminPermission::all();
- return $this->ok([
- "list" => $all->map(function (AdminPermission $m) {
- return [
- "id" => $m->id,
- "name" => $m->name,
- ];
- }),
- ]);
- }
- public function settingMap()
- {
- return $this->ok(
- app(SettingService::class)->settingMap(),
- );
- }
- public function settingSave()
- {
- $data = request()->validate([
- "hot_keywords.id" => "required",
- "hot_keywords.values" => "array",
- ]);
- return $this->ok(app(SettingService::class)->settingSave($data));
- }
- public function allSpec()
- {
- return $this->ok([
- "list" => Spec::get()->map(function (Spec $s) {
- return [
- "id" => $s->id,
- "name" => $s->name,
- "attr_name" => $s->attrs->pluck("name"),
- ];
- }),
- ]);
- }
- public function allCategory()
- {
- return $this->ok([
- "list" => Category::get()->map(function (Category $c) {
- return $c->format();
- }),
- ]);
- }
- }
|