|
@@ -5,6 +5,8 @@ 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
|
|
@@ -56,35 +58,22 @@ class CommonController extends BaseController
|
|
|
public function allSpec()
|
|
|
{
|
|
|
return $this->ok([
|
|
|
- "list" => [
|
|
|
- [
|
|
|
- "id" => 1,
|
|
|
- "name" => "名称",
|
|
|
- "attr_name" => ["红色", "白色"],
|
|
|
- ],
|
|
|
- ],
|
|
|
+ "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" => [
|
|
|
- [
|
|
|
- "id" => 1,
|
|
|
- "name" => "分类名称",
|
|
|
- "level" => 1,
|
|
|
- "parent_id" => 0,
|
|
|
- "parent_name" => "",
|
|
|
- ],
|
|
|
- [
|
|
|
- "id" => 2,
|
|
|
- "name" => "二级分类名称",
|
|
|
- "level" => 2,
|
|
|
- "parent_id" => 1,
|
|
|
- "parent_name" => "上级分类",
|
|
|
- ],
|
|
|
- ],
|
|
|
+ "list" => Category::get()->map(function (Category $c) {
|
|
|
+ return $c->format();
|
|
|
+ }),
|
|
|
]);
|
|
|
}
|
|
|
}
|