コード例 #1
0
ファイル: Photos.php プロジェクト: adamendvy89/intifadah
 public function deleteMe()
 {
     $path = $this->path;
     $slug = $this->slug;
     \Image::delete($path);
     //lets take our time to delete likes and comments
     app('App\\Repositories\\CommentRepository')->deleteByType('photo', $this->id);
     app('App\\Repositories\\LikeRepository')->deleteByType('photo', $this->id);
     //if post is attached lets delete the pic
     if ($this->post_id) {
         app('App\\Repositories\\PostRepository')->delete($this->post_id);
     }
     $this->delete();
     $split = explode('-', $slug);
     if (count($split) > 1) {
         list($name, $id) = $split;
         if (isset($id)) {
             $album = app('App\\Repositories\\PhotoAlbumRepository')->get($id);
             if (!empty($album)) {
                 if ($album->default_photo == $path) {
                     $lastPhoto = app('App\\Repositories\\PhotoRepository')->lastPhoto($slug);
                     if ($lastPhoto) {
                         $album->default_photo = $lastPhoto->path;
                     } else {
                         $album->default_photo = '';
                     }
                     $album->save();
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: ImagesBehavior.php プロジェクト: vsguts/crm
 public function removeImage(Image $image)
 {
     if ($image->table == $this->owner->formName()) {
         $image->delete();
     }
 }