generated from panliang/owl-admin-starter
42 lines
974 B
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;
|
|
}
|
|
}
|