Beispiel #1
0
 public function delete()
 {
     if (is_object($id)) {
         $id = $id->id;
     }
     $asset = Asset::withTrashed()->whereId($id)->first();
     if ($asset) {
         $asset->delete();
     }
     return $this->listener->statusResponse(['asset' => $asset]);
 }
Beispiel #2
0
 public function saveFile($f)
 {
     if ($this->uid == 'missing') {
         return;
     }
     $this->removeOldFile();
     $save_path = $this->getRelativePath();
     $this->filename = $this->getSaveFilename($f->getClientOriginalName());
     $this->org_filename = $f->getClientOriginalName();
     $this->source = $f->getClientOriginalName();
     if (Asset::isImageFile($f)) {
         $this->type = Asset::ASSET_TYPE_IMAGE;
     } else {
         if (Asset::isAudioFile($f)) {
             $this->type = Asset::ASSET_TYPE_AUDIO;
         } else {
             $this->type = Asset::ASSET_TYPE_UNKNOWN;
         }
     }
     if (!File::exists($save_path)) {
         File::makeDirectory($save_path, 0755, true);
     }
     $f->move($save_path, $this->filename);
     $this->save();
 }