コード例 #1
0
 public function participantsUpdate($user_id)
 {
     if ($user = Accounts::where('id', $user_id)->first()) {
         try {
             $post = Input::all();
             if (Input::has('remove_photo')) {
                 if (!empty($user->photo) && File::exists(public_path($user->photo))) {
                     File::delete(public_path($user->photo));
                 }
                 $user->photo = '';
                 if (!empty($user->thumbnail) && File::exists(public_path($user->thumbnail))) {
                     File::delete(public_path($user->thumbnail));
                 }
                 $user->thumbnail = '';
                 foreach (Ulogin::where('user_id', $user->id)->get() as $ulogin) {
                     $ulogin->photo_big = '';
                     $ulogin->photo = '';
                     $ulogin->save();
                 }
             } else {
                 $user->photo = AdminUploadsController::getUploadedFile('photo');
                 $user->thumbnail = '';
             }
             $names = explode(' ', $user->name);
             if (count($names) > 2) {
                 $user->name = @$names[0] . ' ' . @$names[1];
             } else {
                 $user->name = $post['name'];
             }
             $user->email = $post['email'];
             $user->surname = '';
             $user->location = $post['location'];
             $user->phone = $post['phone'];
             $user->age = $post['age'];
             $user->way = $post['way'];
             $user->yad_name = $post['yad_name'];
             $user->load_video = Input::has('load_video') ? 1 : 0;
             $user->local_video = $post['local_video'];
             $user->local_video_date = $post['local_video_date'];
             $user->video = $post['video'];
             $user->video_thumb = $post['video_thumb'];
             $user->skype = $post['skype'];
             $user->save();
             $user->touch();
             return Redirect::route('moderator.participants');
         } catch (Exception $e) {
         }
     }
     return Redirect::back();
 }
コード例 #2
0
 public function profileVideoUpdate()
 {
     $json_request = array('status' => FALSE, 'responseText' => '', 'redirect' => FALSE);
     if (Input::hasFile('video')) {
         $path = Config::get('site.uploads_video_dir') . '/';
         if ($uploaded_file_path = AdminUploadsController::getUploadedFile('video', $path)) {
             if (Auth::user()->load_video && File::exists(public_path(Auth::user()->local_video))) {
                 File::delete(public_path(Auth::user()->local_video));
             }
             Auth::user()->load_video = 1;
             Auth::user()->local_video = $uploaded_file_path;
             Auth::user()->local_video_date = Carbon::now();
             Auth::user()->video = '';
             Auth::user()->save();
             $file_info = array('user_id' => Auth::user()->id, 'file_path' => public_path($uploaded_file_path), 'end' => "\n\r");
             File::append(public_path($path . 'readme.txt'), implode(';', $file_info));
             $json_request['responseText'] = 'Файл успешно загружен.';
             $json_request['status'] = TRUE;
         }
     }
     return Response::json($json_request, 200);
 }