public function deleteCrudImages($data, $rows)
    {
        foreach ($rows as $row) {
            $this->deleteFileIfExists($data->{$row->field});

            $options = json_decode($row->details);

            if (isset($options->thumbnails)) {
                foreach ($options->thumbnails as $thumbnail) {
                    $ext = explode('.', $data->{$row->field});
                    $extension = '.'.$ext[count($ext) - 1];

                    $path = str_replace($extension, '', $data->{$row->field});

                    $thumb_name = $thumbnail->name;

                    $this->deleteFileIfExists($path.'-'.$thumb_name.$extension);
                }
            }
        }

        if ($rows->count() > 0) {
            event(new CrudImagesDeleted($data, $rows));
        }
    }
public function deleteCrudImages($data, $rows)
    {
        foreach ($rows as $row) {
            $this->deleteFileIfExists($data->{$row->field});

            $options = json_decode($row->details);

            if (isset($options->thumbnails)) {
                foreach ($options->thumbnails as $thumbnail) {
                    $ext = explode('.', $data->{$row->field});
                    $extension = '.'.$ext[count($ext) - 1];

                    $path = str_replace($extension, '', $data->{$row->field});

                    $thumb_name = $thumbnail->name;

                    $this->deleteFileIfExists($path.'-'.$thumb_name.$extension);
                }
            }
        }

        if ($rows->count() > 0) {
            event(new CrudImagesDeleted($data, $rows));
        }
    }
public function deleteCrudImages ( $ data , $ rows ) { foreach ( $ rows as $ row ) { $ this -> deleteFileIfExists ( $ data -> { $ row -> field } ) ; $ options = json_decode ( $ row -> details ) ; if ( isset ( $ options -> thumbnails ) ) { foreach ( $ options -> thumbnails as $ thumbnail ) { $ ext = explode ( '.' , $ data -> { $ row -> field } ) ; $ extension = '.' . $ ext [ count ( $ ext ) - 1 ] ; $ path = str_replace ( $ extension , '' , $ data -> { $ row -> field } ) ; $ thumb_name = $ thumbnail -> name ; $ this -> deleteFileIfExists ( $ path . '-' . $ thumb_name . $ extension ) ; } } } if ( $ rows -> count ( ) > 0 ) { event ( new CrudImagesDeleted ( $ data , $ rows ) ) ; } }
Delete all images related to a CRUD item.

@param \Illuminate\Database\Eloquent\Model $data
@param \Illuminate\Database\Eloquent\Model $rows

@return void
Delete all images related to a CRUD item .