1
0
Fork 0
party-rank-server/app/Admin/Services/BannerService.php

42 lines
974 B
PHP

<?php
namespace App\Admin\Services;
use App\ModelFilters\BannerFilter;
use App\Models\{Banner, Keyword};
class BannerService extends BaseService
{
protected array $withRelationships = ['place'];
protected string $modelName = Banner::class;
protected string $modelFilterName = BannerFilter::class;
public function listQuery()
{
$model = $this->getModel();
$filter = $this->getModelFilter();
$query = $this->query();
if ($this->withRelationships) {
$query->with($this->withRelationships);
}
if ($filter) {
$query->filter(request()->input(), $filter);
}
return $query->orderBy('place_id')->sort();
}
public function resloveData($data, $model = null)
{
$place = data_get($data, 'place_id');
if ($place) {
$data['path'] = Keyword::where('id', $place)->value('path') . $place. '-';
}
return $data;
}
}