public static function getByFileable($fileableId) { $model = new static(); return $model->newQuery()->rightJoin($model->getFileableTable(), $model->getTable() . '.id', '=', $model->getFileableTable() . '.fileId')->where('fileableId', $fileableId)->select([$model->getTable() . '.*'])->get(); }
public function getKeyFile() { if (!$this->file && $this->get('uuid')) { $files = File::getByFileable($this->get('uuid')); $this->file = $files->first(); } return $this->file; }