vd/app/Domains/File/Repositories/FileWithRepository.php
2018-11-05 09:26:30 +08:00

63 lines
1.1 KiB
PHP

<?php
namespace App\Domains\File\Repositories;
use App\Core\Repository;
use App\Models\File\FileWith as Model;
class FileWithRepository extends Repository
{
/**
* 是否关闭缓存
*
* @var boolean
*/
protected $cacheSkip = false;
/**
* 是否开启数据转化
*
* @var bool
*/
protected $needTransform = false;
/**
* @var array
*/
protected $fieldSearchable = [
'id' => '=',
'created_at' => 'like',
];
public function model()
{
return Model::class;
}
/**
* 数据格式化
*
* @param mixed $result
*
* @return mixed
*/
public function transform($model)
{
return $model->toArray();
}
/**
* 使用类型查找
*
* @param string $type
* @param string|int $typeid
* @return void
*/
public function withType($type, $typeIds)
{
$typeIds = is_array($typeIds) ? $typeIds : [$typeIds];
$this->model = $this->model->where('type', $type)->whereIn('type_id', $typeIds);
return $this;
}
}