123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?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\GoodsCustom;
- 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();
- }),
- ]);
- }
- public function allCustom()
- {
- return $this->ok([
- "list" => GoodsCustom::get()->map(function (GoodsCustom $c) {
- return [
- "id" => $c->id,
- "name" => $c->title,
- "en_name" => $c->en_title,
- ];
- }),
- ]);
- }
- }
|