generated from liutk/owl-admin-base
0.61
parent
1c228d21e1
commit
0eeadecb45
|
|
@ -13,13 +13,6 @@ class ProjectChildrenController extends Controller
|
||||||
{
|
{
|
||||||
use PaginatorTrait;
|
use PaginatorTrait;
|
||||||
|
|
||||||
public function index(Request $request){
|
|
||||||
$query = ProjectArticle::filter($request->all(), ProjectArticleFilter::class)->sort();
|
|
||||||
$list = $query->childrens()->show()->sort()->paginate($this->resolvePerPage('per_page', 20));
|
|
||||||
|
|
||||||
return $this->json(ProjectChildrenResource::collection($list));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show(ProjectArticle $children){
|
public function show(ProjectArticle $children){
|
||||||
request()->merge(['include_content' => true]);
|
request()->merge(['include_content' => true]);
|
||||||
return $this->json(ProjectChildrenResource::make($children));
|
return $this->json(ProjectChildrenResource::make($children));
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,17 @@ class ProjectController extends Controller
|
||||||
{
|
{
|
||||||
use PaginatorTrait;
|
use PaginatorTrait;
|
||||||
|
|
||||||
public function index(Request $request){
|
public function index(Request $request)
|
||||||
|
{
|
||||||
$query = ProjectCate::filter($request->all(), ProjectCateFilter::class)->sort();
|
$query = ProjectCate::filter($request->all(), ProjectCateFilter::class)->sort();
|
||||||
$list = $query->show()->sort()->paginate($this->resolvePerPage('per_page', 20));
|
$list = $query->show()->sort()->paginate($this->resolvePerPage('per_page', 20));
|
||||||
|
|
||||||
return $this->json(ProjectResource::collection($list));
|
return $this->json(ProjectResource::collection($list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function show(ProjectCate $projectCate, Request $request)
|
||||||
|
{
|
||||||
|
$projectCate->load(['children', 'flows', 'photos', 'advances']);
|
||||||
|
return $this->json(ProjectResource::make($projectCate));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ProjectAdvanceResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => $this->title,
|
||||||
|
'cover' => $this->cover,
|
||||||
|
'description' => $this->description,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ProjectFlowResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => $this->title,
|
||||||
|
'cover' => $this->cover,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ProjectPhotoResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => $this->title,
|
||||||
|
'cover' => $this->cover,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,10 @@ class ProjectResource extends JsonResource
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'title' => $this->title,
|
'title' => $this->title,
|
||||||
'cover' => $this->cover,
|
'cover' => $this->cover,
|
||||||
|
'children' => ProjectChildrenResource::collection($this->whenLoaded('children')),
|
||||||
|
'flows' => ProjectFlowResource::collection($this->whenLoaded('flows')),
|
||||||
|
'photos' => ProjectPhotoResource::collection($this->whenLoaded('photos')),
|
||||||
|
'advances' => ProjectAdvanceResource::collection($this->whenLoaded('advances')),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,6 @@ class ProjectArticle extends Model
|
||||||
->orderBy('created_at', 'desc');
|
->orderBy('created_at', 'desc');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeChildrens($q)
|
|
||||||
{
|
|
||||||
$q->where('type', self::TYPE_ARTICLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tags():Attribute
|
protected function tags():Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
|
|
|
||||||
|
|
@ -42,4 +42,25 @@ class ProjectCate extends Model
|
||||||
$q->orderBy('sort', 'asc')
|
$q->orderBy('sort', 'asc')
|
||||||
->orderBy('created_at', 'desc');
|
->orderBy('created_at', 'desc');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//服务子类
|
||||||
|
public function children()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProjectArticle::class, 'cate')->where('type', ProjectArticle::TYPE_ARTICLE)->show()->sort();
|
||||||
|
}
|
||||||
|
//服务流程
|
||||||
|
public function flows()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProjectArticle::class, 'cate')->where('type', ProjectArticle::TYPE_FLOW)->show()->sort();
|
||||||
|
}
|
||||||
|
//相关图片
|
||||||
|
public function photos()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProjectArticle::class, 'cate')->where('type', ProjectArticle::TYPE_PHOTO)->show()->sort();
|
||||||
|
}
|
||||||
|
//核心优势
|
||||||
|
public function advances()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProjectArticle::class, 'cate')->where('type', ProjectArticle::TYPE_ADVANCE)->show()->sort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,11 @@ Route::middleware('api')->group(function () {
|
||||||
Route::post('captchas', [CaptchaController::class, 'store']);
|
Route::post('captchas', [CaptchaController::class, 'store']);
|
||||||
Route::get('captchas/{captcha}', [CaptchaController::class, 'show']);
|
Route::get('captchas/{captcha}', [CaptchaController::class, 'show']);
|
||||||
|
|
||||||
|
//广告
|
||||||
Route::get('/ads', [AdController::class, 'index']);
|
Route::get('/ads', [AdController::class, 'index']);
|
||||||
|
//业务范围
|
||||||
Route::get('/project_cates', [ProjectController::class, 'index']);
|
Route::get('/project_cates', [ProjectController::class, 'index']);
|
||||||
Route::get('/project_childrens', [ProjectChildrenController::class, 'index']);
|
Route::get('/project_cates/{project_cate}', [ProjectController::class, 'show']);//服务详情
|
||||||
Route::get('/project_childrens/{children}', [ProjectChildrenController::class, 'show']);
|
//业务子类详情
|
||||||
|
Route::get('/project_children/{child}', [ProjectChildrenController::class, 'show']);
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue