/**
  * Removes all uploads based on upload type and the type_id.
  * @param  boolean $upload_type The type of upload ('news', 'gallery', 'section') etc
  * @param  boolean $type_id     The ID of the item (above) that the upload is linked to
  * @param  string  $path_to     There might be a different physical path that the upload is at (not sure why, enter that here)
  * @return int                  Notification of whether or not the upload object was deleted
  */
 public static function remove($upload_type = false, $type_id = false, $path_to = './uploads/')
 {
     if (!$upload_type || !$type_id) {
         return false;
     }
     $uploads = Upload::where('link_type', '=', $upload_type)->where('link_id', '=', $type_id)->get();
     if ($uploads) {
         foreach ($uploads as $upload) {
             if ($upload->filename && file_exists($path_to . $upload->filename)) {
                 @unlink($path_to . $upload->filename);
             }
             if ($upload->small_filename && file_exists($path_to . $upload->small_filename)) {
                 @unlink($path_to . $upload->small_filename);
             }
             if ($upload->thumb_filename && file_exists($path_to . $upload->thumb_filename)) {
                 @unlink($path_to . $upload->thumb_filename);
             }
         }
     }
     return Upload::where('link_type', '=', $upload_type)->where('link_id', '=', $type_id)->delete();
 }
 public function destroy($id)
 {
     Allow::permission($this->module['group'], 'delete');
     if (!Request::ajax()) {
         App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '');
     $element = Upload::where('id', $id)->first();
     if (is_object($element)) {
         #Helper::tad($element);
         #Helper::dd($element->fullpath());
         @unlink($element->fullpath());
         $element->delete();
     }
     $json_request['responseText'] = 'Удалено';
     $json_request['status'] = TRUE;
     return Response::json($json_request, 200);
 }
Beispiel #3
0
 public static function remove_singular($upload_id = false, $path_to_store = false)
 {
     if (!$upload_id) {
         return false;
     }
     if (!$path_to_store) {
         $path_to_store = path('public') . 'uploads/';
     }
     $uploads = Upload::where('id', '=', $upload_id)->get();
     if ($uploads) {
         foreach ($uploads as $upload) {
             if ($upload->filename && file_exists($path_to_store . $upload->filename)) {
                 @unlink($path_to_store . $upload->filename);
             }
             if ($upload->small_filename && file_exists($path_to_store . $upload->small_filename)) {
                 @unlink($path_to_store . $upload->small_filename);
             }
             if ($upload->thumb_filename && file_exists($path_to_store . $upload->thumb_filename)) {
                 @unlink($path_to_store . $upload->thumb_filename);
             }
         }
     }
     return Upload::where('id', '=', $upload_id)->delete();
 }
 public function saveAboutUploads()
 {
     $file_1_db = Upload::where('where', 'about_1')->first();
     if (empty($file_1_db)) {
         $file_1_row = new Upload();
         $file_1_row->where = 'about_1';
     } else {
         $file_1_row = $file_1_db;
     }
     // If there is a file then lets upload it
     $file_1 = Input::file('download_1_file');
     if ($file_1) {
         $file = Input::file('download_1_file');
         $destinationPath = 'uploads/about/';
         $extension = $file->getClientOriginalExtension();
         $filename = str_random(12) . '.' . $extension;
         $upload_success = Input::file('download_1_file')->move($destinationPath, $filename);
         if ($upload_success) {
             $file_1_row->file_location = $destinationPath . $filename;
             $file_1_row->file_type = $extension;
             $file_1_row->file_name = $file->getClientOriginalName();
             $file_1_row->title = Input::get('download_1');
             $file_1_row->save();
         }
     }
     $file_2_db = Upload::where('where', 'about_2')->first();
     if (empty($file_2_db)) {
         $file_2_row = new Upload();
         $file_2_row->where = 'about_2';
     } else {
         $file_2_row = $file_2_db;
     }
     // If there is a file then lets upload it
     $file_1 = Input::file('download_2_file');
     if ($file_1) {
         $file = Input::file('download_2_file');
         $destinationPath = 'uploads/about/';
         $extension = $file->getClientOriginalExtension();
         $filename = str_random(12) . '.' . $extension;
         $upload_success = Input::file('download_2_file')->move($destinationPath, $filename);
         if ($upload_success) {
             $file_2_row->file_location = $destinationPath . $filename;
             $file_2_row->file_type = $extension;
             $file_2_row->file_name = $file->getClientOriginalName();
             $file_2_row->title = Input::get('download_2');
             $file_2_row->save();
         }
     }
     return Redirect::back();
 }
Beispiel #5
0
 public function associateAdvancedUploads()
 {
     $class = get_class($this);
     Upload::where('uploadable_type', $class)->where('uploadable_id', 0)->where('token', csrf_token())->update(['id' => $this->id]);
 }
<?
/**
 * TITLE: Путеводитель
 * AVAILABLE_ONLY_IN_ADVANCED_MODE
 */
?>
<?php 
if ($infrastructures = Dictionary::valuesBySlug('infrastructures', NULL, 'all', TRUE)) {
    foreach ($infrastructures as $index => $infrastructure) {
        if ($infrastructure['photo']) {
            $infrastructures[$index]['photo_path'] = Upload::where('id', $infrastructure['photo'])->pluck('path');
        }
    }
}
?>
@extends(Helper::layout())
@section('style')
@stop
@section('content')
    <div class="half-page infra-page">
        <div id="infra-map" class="infra-map"></div>
        <div class="wrapper">
            <div class="page__left">
                <div class="tabs-title">
                    <h1 class="us-title title-red"><span>{{ $page->seo->h1 }}</span></h1>
                    <div class="tabs-right">
                        <div class="right-cont">
                            <a href="{{ pageurl('raspolojenie') }}" class="title__link">Расположение</a>
                        </div>
                    </div>
                </div>