private function createFile($path, $file, $table, $table_id)
 {
     $path .= "files/{$table}/";
     $fileType = last(explode('.', $file->getClientOriginalName()));
     $name = str_replace(" ", "_", $file->getClientOriginalName());
     $path .= $name;
     //insere o ficheiro na pasta
     $this->uploadManager->saveFile($path, \File::get($file));
     //cria a Media
     $media = new Media();
     $media->path = $path;
     $media->type = $file->getClientMimeType();
     $media->name = $name;
     $media->table = $table;
     $media->table_id = $table_id;
     return $media->save() ? $media->id : false;
 }
Exemplo n.º 2
0
 /**
  * Return the description of spec in multiple langs
  * @return mixed
  */
 public function getImageAttribute()
 {
     return Media::where('table', $this->table)->where('table_id', $this->id)->first();
 }
Exemplo n.º 3
0
 /**
  * Medias attribute retuned by Medias Table
  * @return mixed
  */
 public function getMediasAttribute()
 {
     return Media::where('table', $this->table)->where('table_id', $this->id)->get();
 }
Exemplo n.º 4
0
 public function file()
 {
     return Media::where('table', $this->table)->where('table_id', $this->id)->first();
 }