public static function _get($attributes = '')
 {
     // Extract
     extract($attributes);
     if (!isset($name)) {
         $name = '';
     }
     return Slider::get($name);
 }
 public function storeSlider()
 {
     $slide = new Slider();
     $input = ["nom" => Input::get('nom'), "alt" => Input::get('alt')];
     $rules = array('nom' => 'required|max:255', 'alt' => 'required|max:255');
     $messages = array('required' => ":attribute est requis pour l'ajout d'une nouvelle image au carousel.", 'max' => ':attribute est trop long.');
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to(URL::previous())->withErrors($validator);
     } else {
         $uploadedImage = Input::file('image');
         // Création d'un nom aléatoire pour l'enregistrement
         $fileName = md5(time() + rand(0, 1000)) . '.jpg';
         $savePath = public_path() . '/uploads/slider/';
         $extension = strtolower($uploadedImage->getClientOriginalExtension());
         if ($extension == "jpg" || $extension == "jpeg" || $extension == "png") {
             // Si on a choisi de rendimensionner
             if (Input::get('resample') != null) {
                 // Récupération de la taille de l'image envoyée
                 list($uploadedWidth, $uploadedHeight) = getimagesize($uploadedImage);
                 // Nouvelles dimensions
                 $newWidth = 1165;
                 $newHeight = 350;
                 // Création d'une nouvelle image vide et sample de l'image envoyée
                 $newImage = imagecreatetruecolor($newWidth, $newHeight);
                 if ($extension == "jpg" || $extension == "jpeg") {
                     $uploadedImageSample = imagecreatefromjpeg($uploadedImage);
                 } else {
                     $uploadedImageSample = imagecreatefrompng($uploadedImage);
                 }
                 // Rendimensionnement et enregistrement de la nouvelle image
                 imagecopyresampled($newImage, $uploadedImageSample, 0, 0, 0, 0, $newWidth, $newHeight, $uploadedWidth, $uploadedHeight);
                 imagejpeg($newImage, $savePath . $fileName, 100);
             } else {
                 $uploadedImage->move($savePath, $fileName);
             }
             // Lien en BDD et position (max+1)
             $input['link'] = $fileName;
             $input['pos'] = Slider::get()->max('pos') + 1;
             Session::flash('flash_msg', "La nouvelle image a bien été ajoutée.");
             Session::flash('flash_type', "success");
             $slide->fill($input)->save();
             return Redirect::to("/admin/slider");
         } else {
             Session::flash('flash_msg', "Le fichier importé n'est pas valide (jpeg ou png uniquement).");
             Session::flash('flash_type', "fail");
             return Redirect::to("/admin/slider");
         }
     }
 }
 public function getSlider($id = '')
 {
     $slides_menu = Slider::get(['id', 'name']);
     $slide = Slider::where('id', $id)->get();
     $view = array('slides_menu' => $slides_menu, 'slides' => $slide, 'row' => !empty($slide[0]) ? $slide[0] : '');
     return View::make('admin.slider', $view);
 }
Exemple #4
0
 Route::get("dashboard/usermanagement", ["as" => "user-management-page", "uses" => "UserManagement@userManagementPage"]);
 Route::get('dashboard/user/{slug}', array('as' => 'user-view', 'uses' => 'UserManagement@viewUser'));
 Route::get('dashboard/user/activate/{slug}', array('as' => 'user-active', 'uses' => 'UserManagement@activeUser'));
 Route::get('dashboard/user/deactivate/{slug}', array('as' => 'user-deactive', 'uses' => 'UserManagement@deactiveUser'));
 // Content Management
 Route::get("dashboard/add-content", ["as" => "add-content-page", "uses" => "ContentManagement@addContent"]);
 Route::get("dashboard/manage-content", ["as" => "cms", "uses" => "ContentManagement@index"]);
 Route::get("dashboard/edit-content/{id}", ["as" => "edit-content-page", "uses" => "ContentManagement@edit"]);
 Route::get('dashboard/change-settings', array('as' => 'change-settings-page', 'uses' => 'ContentManagement@settings'));
 // Slider
 Route::get('dashboard/slider', array('as' => 'slider-page', 'uses' => 'SliderController@index'));
 Route::get('dashboard/add-slider', array('as' => 'add-slider-page', 'uses' => 'SliderController@addSliderPage'));
 Route::get('dashboard/edit-slider/{id}', array('as' => 'view-slider-page', 'uses' => 'SliderController@edit'));
 Route::get('dashboard/getId', function () {
     if (Request::ajax()) {
         $query = Slider::get();
         foreach ($query as $row) {
             $id = $row->slider_id;
         }
         return $id + 1;
     }
 });
 // Contact Info
 Route::controller('dashboard/contact-info', 'ContactController');
 // Order
 Route::controller('dashboard/order', 'OrderController');
 // Support
 Route::controller("dashboard/support", "SupportController");
 // Notice
 Route::controller("dashboard/notice", "NoticeController");
 // Content Image