コード例 #1
0
ファイル: DbFileRepository.php プロジェクト: ahk-ch/chamb.net
 /**
  * @param File $file
  * @param      $data
  *
  * @return File|false
  */
 public function update(File $file, $data)
 {
     if (!is_null($file->path)) {
         $currentFilePath = $file->path;
     }
     $file->fill(array_merge($data, [File::PATH => FilesStorage::getFilesDirectory() . $data[File::CLIENT_ORIGINAL_NAME]]));
     $fileIsStored = Storage::put($file->path, file_get_contents($data[File::TEMPORARY_PATH]));
     if (!$fileIsStored || !$file->save()) {
         return false;
     }
     if (isset($currentFilePath)) {
         Storage::delete($currentFilePath);
     }
     return $file;
 }
コード例 #2
0
 /**
  * Store an article on the storage.
  *
  * @param array $fillable Validated array parameters: author_id, industry_id, thumbnail_id
  *
  * @return Article|false
  */
 public function store(array $fillable)
 {
     $article = new Article($fillable);
     $article->assignAuthor(User::find($fillable['author_id']));
     $article->assignIndustry(Industry::find($fillable['industry_id']));
     $article->assignThumbnail(File::find($fillable['thumbnail_id']));
     return $article->save() ? $article : false;
 }
コード例 #3
0
 /**
  * Update the logo of a company.
  *
  * @param Company $company
  * @param         $logoId
  *
  * @return Company|false
  */
 public function assignLogoById(Company $company, $logoId)
 {
     $logo = AhkFile::find($logoId);
     $company->logo()->associate($logo);
     return $company->save() ? $company : false;
 }