12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Repositories\Eloquent;
- use App\Repositories\Enums\ModelStatusEnum;
- use Prettus\Repository\Eloquent\BaseRepository;
- use Prettus\Repository\Criteria\RequestCriteria;
- use App\Contracts\Repositories\ResourceRepository;
- use App\Repositories\Models\Base\Resource;
- use App\Repositories\Validators\ResourceValidator;
- /**
- * Class ResourceRepositoryEloquent.
- *
- * @package namespace App\Repositories\Eloquent;
- */
- class ResourceRepositoryEloquent extends BaseRepository implements ResourceRepository
- {
- /**
- * Specify Model class name
- *
- * @return string
- */
- public function model()
- {
- return Resource::class;
- }
- /**
- * Boot up the repository, pushing criteria
- */
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- public function insertResource($path, $name, $original_name, $url, $size = 0, $disk = 'public', $status = ModelStatusEnum::OK)
- {
- $this->model->path = $path;
- $this->model->name = $name;
- $this->model->original_name = $original_name;
- $this->model->url = $url;
- $this->model->disk = $disk;
- $this->model->size = $size;
- $this->model->status = $status;
- $this->model->saveOrFail();
- return $this->model;
- }
- }
|