generated from liutk/owl-admin-base
0.62
parent
0eeadecb45
commit
4b438defb6
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Traits\PaginatorTrait;
|
||||||
|
use App\Models\Ad;
|
||||||
|
use App\Models\Filters\AdFilter;
|
||||||
|
use App\Http\Resources\AdResource;
|
||||||
|
|
||||||
|
class AdController extends Controller
|
||||||
|
{
|
||||||
|
use PaginatorTrait;
|
||||||
|
|
||||||
|
public function index(Request $request){
|
||||||
|
$query = Ad::filter($request->all(), AdFilter::class)->sort();
|
||||||
|
$list = $query->show()->sort()->paginate($this->resolvePerPage('per_page', 20));
|
||||||
|
|
||||||
|
return $this->json(AdResource::collection($list));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,8 +13,8 @@ class ProjectChildrenController extends Controller
|
||||||
{
|
{
|
||||||
use PaginatorTrait;
|
use PaginatorTrait;
|
||||||
|
|
||||||
public function show(ProjectArticle $children){
|
public function show(ProjectArticle $child){
|
||||||
request()->merge(['include_content' => true]);
|
request()->merge(['include_content' => true]);
|
||||||
return $this->json(ProjectChildrenResource::make($children));
|
return $this->json(ProjectChildrenResource::make($child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,7 +18,7 @@ class ProjectResource extends JsonResource
|
||||||
'title' => $this->title,
|
'title' => $this->title,
|
||||||
'cover' => $this->cover,
|
'cover' => $this->cover,
|
||||||
'children' => ProjectChildrenResource::collection($this->whenLoaded('children')),
|
'children' => ProjectChildrenResource::collection($this->whenLoaded('children')),
|
||||||
'flows' => ProjectFlowResource::collection($this->whenLoaded('flows')),
|
'flows' => ProjectFlowResource::make($this->whenLoaded('flows')),
|
||||||
'photos' => ProjectPhotoResource::collection($this->whenLoaded('photos')),
|
'photos' => ProjectPhotoResource::collection($this->whenLoaded('photos')),
|
||||||
'advances' => ProjectAdvanceResource::collection($this->whenLoaded('advances')),
|
'advances' => ProjectAdvanceResource::collection($this->whenLoaded('advances')),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class ProjectCate extends Model
|
||||||
//服务流程
|
//服务流程
|
||||||
public function flows()
|
public function flows()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ProjectArticle::class, 'cate')->where('type', ProjectArticle::TYPE_FLOW)->show()->sort();
|
return $this->hasOne(ProjectArticle::class, 'cate')->where('type', ProjectArticle::TYPE_FLOW)->show()->sort();
|
||||||
}
|
}
|
||||||
//相关图片
|
//相关图片
|
||||||
public function photos()
|
public function photos()
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class ProjectArticleService extends BaseService
|
||||||
$columns = $this->getTableColumns();
|
$columns = $this->getTableColumns();
|
||||||
$model = $this->getModel();
|
$model = $this->getModel();
|
||||||
|
|
||||||
$isEnable = Arr::get($data, 'is_enabled');
|
$isEnable = Arr::get($data, 'is_enable');
|
||||||
$publishedAt = Arr::get($data, 'published_at');
|
$publishedAt = Arr::get($data, 'published_at');
|
||||||
if ($isEnable && empty($publishedAt)) {
|
if ($isEnable && empty($publishedAt)) {
|
||||||
$data['published_at'] = now();
|
$data['published_at'] = now();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue