Exemple #1
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function Home()
 {
     $lc = app()->getlocale();
     $channel = \Model\Channel\ModelName::general();
     if ($lc == 'kg') {
         $generalPosts = \Model\Post\ModelName::general($channel)->published()->languagekg()->take(6)->skip(0)->orderBy('id', 'desc')->get();
         $projects = \Model\Project\ModelName::having('name', '<>', '')->get();
     } elseif ($lc == 'ru') {
         $generalPosts = \Model\Post\ModelName::general($channel)->published()->languageru()->take(6)->skip(0)->orderBy('id', 'desc')->get();
         $projects = \Model\Project\ModelName::where('nameRu', '<>', '')->get();
     }
     $rDayVideo = \Model\Media\ModelName::having('dayVideo', '=', '1')->take(1)->skip(0)->orderBy('created_at', 'desc')->first();
     if ($rDayVideo != null) {
         $dayVideo = $rDayVideo;
     } elseif ($rDayVideo == null) {
         $dayVideoResult = \Model\Media\ModelName::take(1)->skip(0)->orderBy('id', 'desc')->first();
         if ($dayVideoResult != null) {
             $dayVideo = $dayVideoResult;
         } else {
             $dayVideo = 'KhJUlC4aJZM';
         }
     }
     $backgroundMain = \Model\Background\ModelName::where('published', '=', true)->first();
     $peopleReporters = \Model\PeopleReporter\ModelName::where('published', '=', true)->get();
     // FotoParent - photo gallery
     $photoParent = \Model\PhotoParent\ModelName::where('published', '=', true)->first();
     if ($photoParent != null) {
         $images = json_decode($photoParent->images);
         // array of images
     } else {
         $images = 1;
     }
     $MediaCategories = \Model\MediaCategory\ModelName::get();
     $mediaPosts = \Model\Media\ModelName::orderBy('id', 'desc')->get();
     $categoriesVideos = array();
     foreach ($MediaCategories as $MediaCategory) {
         $CategoryVideos = \Model\Media\ModelName::where('videoType', '=', $MediaCategory->videoType)->orderBy('id', 'desc')->take(9)->get();
         $categoriesVideos = array_add($categoriesVideos, $MediaCategory->videoType, $CategoryVideos);
     }
     $mediaLastVideos = \Model\Media\ModelName::orderBy('id', 'desc')->take(9)->get();
     return view('Front::home', ['images' => $images, 'generalPosts' => $generalPosts, 'dayVideo' => $dayVideo, 'positionTop' => $this->positionTop, 'positionRight' => $this->positionRight, 'positionCenter' => $this->positionCenter, 'positionBottom' => $this->positionBottom, 'peopleReporters' => $peopleReporters, 'backgroundMain' => $backgroundMain, 'MediaCategories' => $MediaCategories, 'categoriesVideos' => $categoriesVideos, 'mediaLastVideos' => $mediaLastVideos, 'projects' => $projects]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(PeopleReporter $peopleReporter)
 {
     $peopleReporter->delete();
     return redirect()->route('admin.peopleReporter.index');
 }
Exemple #3
0
 public function ReporterAdd(Request $request)
 {
     $lc = app()->getlocale();
     $backgroundMain = \Model\Background\ModelName::where('published', '=', true)->first();
     $reporter = \Model\PeopleReporter\ModelName::create($request->except('images', 'video', 'q'));
     $images = $request->file('images');
     $rules = array('image' => 'image');
     $result = array();
     if ($request->hasFile('images')) {
         foreach ($images as $key => $image) {
             $target = array('image' => $image);
             $validator = Validator::make($target, $rules);
             if ($validator->fails()) {
                 return redirect()->route('front.reporter');
             } else {
                 $storage = \Storage::disk('public');
                 $destinationPath = 'froala/uploads';
                 $storage->makeDirectory($destinationPath);
                 $filename = time() . $key . '.' . $image->getClientOriginalExtension();
                 Image::make($_FILES['images']['tmp_name'][$key])->heighten(600)->save($destinationPath . '/' . $filename);
                 $files_array = array();
                 $files_array = array_collapse([$files_array, ['id' => $key + 1, 'name' => $filename]]);
                 $result = array_add($result, $key, $files_array);
                 $jsonresult = json_encode($result);
                 $reporter->thumbnail = $jsonresult;
                 $reporter->save();
             }
         }
     }
     $video = $request->file('video');
     $video_rules = array('video' => 'mimes:mimes:m4v,avi,flv,mp4,mov,3gp | max:51200');
     if ($request->hasFile('video')) {
         $targetVideo = array('video' => $video);
         $validator = Validator::make($targetVideo, $video_rules);
         if ($validator->fails()) {
             return redirect()->route('front.reporter');
         } else {
             $storage = \Storage::disk('public');
             $destinationPath = 'froala/videos';
             $storage->makeDirectory($destinationPath);
             $filename = time() . '.' . $video->getClientOriginalExtension();
             $video->move($destinationPath, $filename);
             $reporter->video = $filename;
             $reporter->save();
         }
     }
     return redirect()->route('front.reporter');
 }