示例#1
2
 public function import($entity)
 {
     $appHelper = new libs\AppHelper();
     $className = $appHelper->getNameSpace() . $entity;
     $model = new $className();
     $table = $model->getTable();
     $columns = \Schema::getColumnListing($table);
     $key = $model->getKeyName();
     $notNullColumnNames = array();
     $notNullColumnsList = \DB::select(\DB::raw("SHOW COLUMNS FROM `" . $table . "` where `Null` = 'no'"));
     if (!empty($notNullColumnsList)) {
         foreach ($notNullColumnsList as $notNullColumn) {
             $notNullColumnNames[] = $notNullColumn->Field;
         }
     }
     $status = \Input::get('status');
     $filePath = null;
     if (\Input::hasFile('import_file') && \Input::file('import_file')->isValid()) {
         $filePath = \Input::file('import_file')->getRealPath();
     }
     if ($filePath) {
         \Excel::load($filePath, function ($reader) use($model, $columns, $key, $status, $notNullColumnNames) {
             $this->importDataToDB($reader, $model, $columns, $key, $status, $notNullColumnNames);
         });
     }
     $importMessage = $this->failed == true ? \Lang::get('panel::fields.importDataFailure') : \Lang::get('panel::fields.importDataSuccess');
     return \Redirect::to('panel/' . $entity . '/all')->with('import_message', $importMessage);
 }
示例#2
1
 public function createParent()
 {
     $input = Input::all();
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'));
     }
     $input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
     $input['collegeid'] = Session::get('user')->collegeid;
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     $removed = array('_token', 'password', 'cpassword');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Parent::saveFormData($input);
     return $input;
 }
 public function edit($id)
 {
     $exist = Book::where('id', $id)->count();
     if ($exist == 0) {
         Session::put('msgfail', 'Invalid input.');
         return Redirect::back()->withInput();
     }
     $rules = array('name' => 'required', 'author' => 'required', 'date' => 'required', 'file' => 'mimes:jpeg,bmp,png');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         Session::put('msgfail', 'Invalid input.');
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         $book_save = Book::find($id);
         $destinationPath = '';
         $filename = $book_save->file;
         if (Input::hasFile('file')) {
             $file = Input::file('file');
             $destinationPath = public_path() . '/uploads/book/';
             $filename = str_random(6) . '_' . $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
         }
         $book_save->name = strip_tags(Input::get('name'));
         $book_save->author = strip_tags(Input::get('author'));
         $book_save->date = Input::get('date');
         $book_save->file = $filename;
         $book_save->save();
         Session::put('msgsuccess', 'Successfully edited book.');
         return Redirect::to("/books");
     }
 }
示例#4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = ['title' => 'required', 'content' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/teacher/posts/create')->withErrors($validator);
     } else {
         $post = new Post();
         $post->title = Input::get('title');
         $post->content = Input::get('content');
         // variables liées à la gestion de l'image
         $destinationPath = '';
         $filename = '';
         if (Input::hasFile('image')) {
             $file = Input::file('image');
             $destinationPath = $destinationPath = public_path() . '/img/';
             $filename = $file->getClientOriginalName();
             $uploadSuccess = $file->move($destinationPath, $filename);
             $post->url_thumbnail = $filename;
         }
         $post->abstract = Str::words($post->content, 20, '...');
         $post->user_id = Auth::user()->id;
         $post->save();
         /*echo "<pre>";
         		var_dump(public_path().'\\img\\'.'lol.jpg');
         		echo '</pre>';*/
         Session::flash('message_success', 'L\'article a bien été ajouté');
         return Redirect::to('/teacher/posts');
     }
 }
 /**
  * Update the specified powerful in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $powerful = Powerful::findOrFail($id);
     $rules = array('name' => 'required', 'icon' => 'image');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //upload powerful icon
     if (Input::hasFile('icon')) {
         //delete old icon
         if (File::exists($powerful->icon)) {
             File::delete($powerful->icon);
         }
         //create new icon
         $name = md5(time() . Input::file('icon')->getClientOriginalName()) . '.' . Input::file('icon')->getClientOriginalExtension();
         $folder = "public/uploads/powerful";
         Input::file('icon')->move($folder, $name);
         $path = $folder . '/' . $name;
         //update new path
         $data['icon'] = $path;
     } else {
         unset($data['icon']);
     }
     $powerful->update($data);
     return Redirect::route('admin.powerful.index')->with('message', 'Item had updated!');
 }
示例#6
0
 public static function uploadImage($user_id)
 {
     $error_code = ApiResponse::OK;
     if (User::where('user_id', $user_id)->first()) {
         $profile = Profile::where('user_id', $user_id)->first();
         if (Input::hasFile('file')) {
             $file = Input::file('file');
             $destinationPath = public_path() . '/images/' . $user_id . '/avatar';
             $filename = date('YmdHis') . '_' . $file->getClientOriginalName();
             $extension = $file->getClientOriginalExtension();
             if (!File::isDirectory($destinationPath)) {
                 File::makeDirectory($destinationPath, $mode = 0777, true, true);
             }
             $upload_success = $file->move($destinationPath, $filename);
             $profile->image = 'images/' . $user_id . '/avatar/' . $filename;
             $profile->save();
             $data = URL::asset($profile->image);
         } else {
             $error_code = ApiResponse::MISSING_PARAMS;
             $data = null;
         }
     } else {
         $error_code = ApiResponse::UNAVAILABLE_USER;
         $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_USER);
     }
     return array("code" => $error_code, "data" => $data);
 }
 public function postUpload()
 {
     $agente = Agente::find(1);
     if (Input::hasFile('file')) {
         $file = Input::file('file');
         $name = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $size = File::size($file);
         //dd($extension);
         $data = array('nombre' => $name, 'extension' => $extension, 'size' => $size);
         $rules = array('extension' => 'required|mimes:jpeg');
         $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'unique' => 'La factura ingresada ya está agregada en la base de datos.', 'confirmed' => 'Los passwords no coinciden.', 'mimes' => 'El campo :attribute debe ser un archivo de tipo :values.');
         $validation = Validator::make($rules, $messages);
         if ($validation->fails()) {
             return Redirect::route('logo-post')->withInput()->withErrors($validation);
         } else {
             if ($extension != 'jpg') {
                 return Redirect::route('logo-post')->with('global', 'Es necesario que la imagen sea de extension .jpg.');
             } else {
                 $path = public_path() . '/assets/img/';
                 $newName = 'logo';
                 $subir = $file->move($path, $newName . '.' . $extension);
                 return Redirect::route('agente.index')->with('create', 'El logo ha sido actualizado correctamente!');
             }
         }
     } else {
         return Redirect::route('logo-post')->with('global', 'Es necesario que selecciones una imagen.');
     }
 }
示例#8
0
 public function postPublish()
 {
     $msg = 'Report Successfully Published';
     $inputs = Input::except('notify');
     foreach (Input::all() as $key => $single_input) {
         if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
             unset($inputs[$key]);
         }
     }
     $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $inputs['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     if (!Input::hasFile('kid_image')) {
         unset($inputs['kid_image']);
     } else {
         $file = Input::file('kid_image');
         $destination_path = 'admin/images/upload/';
         $filename = str_random(15) . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $inputs['kid_image'] = $destination_path . $filename;
     }
     if (Input::get('clicked') == 'Success') {
         // if the report is marked as a success
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         //if the report is updated or published
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Found::where('id', '=', Input::get('id'))->update($inputs);
     return Redirect::to('admin/found/published')->with('success', $msg);
 }
 public function createStudent()
 {
     $validator = $this->validateStudent(Input::all());
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to('student-new')->withErrors($messages)->withInput(Input::except('password', 'password_confirmation'));
     }
     $input = Input::all();
     //$input['dob'] = date('m-d-Y H:i:s', strtotime(Input::get('dob')));
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     $input['collegeid'] = Session::get('user')->collegeid;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'), $user->id);
     }
     $removed = array('password', 'password_confirmation');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Student::saveFormData($input);
     return Redirect::to('student');
 }
示例#10
0
 public function postUpload()
 {
     $data = Input::all();
     $rules = array('category' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         if (Input::hasFile('file')) {
             $contents = file_get_contents(Input::file('file')->getRealPath());
             $decoded = Bencode::decode($contents);
             $torrent = new Torrent();
             $torrent->name = $decoded['info']['name'];
             $torrent->size = 0;
             $torrent->downloads = 0;
             $torrent->file = $contents;
             $torrent->category_id = $data['category'];
             $torrent->uploader_id = Auth::user()->id;
             $torrent->save();
             $files = array();
             if (!empty($decoded['info']['files'])) {
                 foreach ($decoded['info']['files'] as $file) {
                     $files[] = array('torrent_id' => $torrent->id, 'name' => implode('/', $file['path']), 'size' => $file['length']);
                     $torrent->size += $file['length'];
                 }
             } else {
                 $files[] = array('torrent_id' => $torrent->id, 'name' => $decoded['info']['name'], 'size' => $decoded['info']['length']);
                 $torrent->size += $decoded['info']['length'];
             }
             //http://stackoverflow.com/questions/12702812/bulk-insertion-in-laravel-using-eloquent-orm
             TorrentFile::insert($files);
             $torrent->save();
             return Redirect::action('TorrentController@getDetails', array($torrent->id))->with('success', 'Your torrent has been added!');
         }
     }
     return Redirect::to('/upload')->withInput()->withErrors($validator);
 }
 public function store()
 {
     if ($_POST) {
         $input = Input::all();
         $rules = array('username' => 'required|unique:users', 'password' => 'required', 'email' => 'required|unique:users|email', 'firstname' => 'required|Alpha', 'lastname' => 'required|alpha_dash', 'city' => 'required', 'country' => 'required|Alpha', 'recaptcha_response_field' => 'required|recaptcha');
         $validator = Validator::make($input, $rules);
         if ($validator->fails()) {
             return Redirect::to('register')->withInput()->withErrors($validator);
         } else {
             $user = new User();
             $user->username = Input::get('username');
             $user->password = Hash::make(Input::get('password'));
             $user->firstname = Input::get('firstname');
             $user->lastname = Input::get('lastname');
             $user->email = Input::get('email');
             $user->city = Input::get('city');
             $user->country = Input::get('country');
             $user->organisation = Input::get('organisation');
             $user->description = Input::get('description');
             $user->picture = '';
             $user->suspended = 0;
             if (Input::hasFile('picture')) {
                 $file = Input::file('picture');
                 $pixpath = '/uploads/pix/user/';
                 $destinationPath = public_path() . $pixpath;
                 $filename = $user->username . '.' . $file->getClientOriginalExtension();
                 $file->move($destinationPath, $filename);
                 $user->picture = base64_encode($pixpath . $filename);
             }
             $user->save();
             return Redirect::to('login')->with('successmessage', trans('master.registersuccess'));
         }
     }
     return Redirect::route('register.index')->withInput()->withErrors($s->errors());
 }
 public function postUploads()
 {
     $id = Auth::user()->id;
     // $file = Input::file('image');
     // $input = array('image' => $file);
     // $rules = array(
     // 	'image' => 'image'
     // );
     // $validator = Validator::make($input, $rules);
     // if ( $validator->fails() )
     // {
     // 	return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
     // }
     // else {
     if (Input::hasFile('image')) {
         $file = Input::file('image');
         //$destinationPath = 'uploads/' .$id;
         //$destinationPath = public_path().'/img/'.$id;
         $destinationPath = app_path() . '/foundation-5.4.0/profilePic/' . $id;
         $file->move($destinationPath, $id . '.JPEG');
         //Input::file('image')->move($destinationPath);
         // $ = 'uploads/';
         // $filename = $id;
         // Input::file('image')->move($destinationPath, $fileName);
         //Input::file('image')->move($destinationPath, $filename);
         //return Response::json(['success' => true, 'file' => asset($destinationPath.$filename)]);
         return Redirect::to('myprofile');
     } else {
         return 'no file';
     }
 }
 public function addPhotos()
 {
     if (\Input::hasFile('image')) {
         $images = \Input::file('image');
         if (!$this->photoRepository->imagesMetSizes($images)) {
             return 0;
         }
         //confirm if one of the size is more than admin set value
         $event = $this->eventRepository->get(\Input::get('val.id'));
         $param = ['path' => 'events/' . $event->id . '/posts', 'slug' => 'photos', 'userid' => $event->user->id, 'event_id' => $event->id, 'privacy' => 5];
         $photos = [];
         $paths = [];
         foreach ($images as $im) {
             $i = $this->photoRepository->upload($im, $param);
             $paths[] = $i;
             $photos[] = $this->photoRepository->getByLink($i);
         }
         //help this event to post to its timeline
         $this->postRepository->add(['type' => 'event', 'content_type' => 'image', 'type_content' => $paths, 'event_id' => $event->id, 'privacy' => 1]);
         $content = "";
         foreach ($photos as $photo) {
             if ($photo) {
                 $content .= (string) $this->theme->section('photo.display-photo', ['photo' => $photo]);
             }
         }
         return $content;
     }
     return '0';
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $imageName = '';
     $imagePath = public_path() . '/img/';
     if (Input::hasFile('photo')) {
         $img = Input::file('photo');
         $imageName = str_random(6) . '_' . $img->getClientOriginalName();
         $img->move($imagePath, $imageName);
         $img = Image::make($imagePath . $imageName);
         $img->save($imagePath . $imageName);
         $thumb = Image::make($imagePath . $imageName);
         $thumbName = $imageName;
         $thumbPath = public_path() . '/thumbs/img/';
         $thumb->resize(100, 100);
         $thumb->save($thumbPath . $thumbName);
         $imgEntry = new Photo();
         $imgEntry->user_id = Auth::user()->id;
         $imgEntry->caption = Input::get('caption');
         $imgEntry->path = 'img/' . $imageName;
         $imgEntry->save();
         return Response::json(array('error' => false, 'message' => 'Upload successful.'), 200);
     } else {
         return Response::json(array('error' => 'true', 'photos' => null), 200);
     }
 }
 public function apply($id)
 {
     $job = DB::select("EXEC spJobByID_Select @JobID = {$id}")[0];
     $data = [];
     $data['job'] = $job;
     $data['form'] = Input::all();
     $email = Input::get('email');
     $name = Input::get('name');
     if (Input::hasFile('cv')) {
         $newfilename = Str::slug($name) . '_cv_' . uniqid() . '.' . Input::file('cv')->getClientOriginalExtension();
         Input::file('cv')->move(public_path() . '/uploads/cvs/', $newfilename);
         Mail::send('emails.jobs.apply', $data, function ($message) use($email, $name, $newfilename, $job) {
             $message->to($email, $name)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->bcc($job->OperatorEmail, $job->OperatorName . ' ' . $job->OperatorSurname)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->attach(public_path() . '/uploads/cvs/' . $newfilename);
         });
     } else {
         // Send email to KDC
         Mail::send('emails.jobs.apply', $data, function ($message) use($email, $name, $job) {
             $message->to($email, $name)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->bcc($job->OperatorEmail, $job->OperatorName . ' ' . $job->OperatorSurname)->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
             $message->bcc('*****@*****.**', 'KDC')->subject('APPLICATION RECEIVED for ' . $job->JobTitle . ' REF: ' . $job->JobRefNo);
         });
     }
     return Redirect::back()->withInfo('Your application has been sent');
 }
示例#16
0
 public function update($id)
 {
     if (Auth::id() != $id) {
         return Redirect::to('http://google.com');
     }
     $user = Auth::User();
     $validator = Validator::make(Input::all(false), ['email' => 'required|email|unique:users,email,' . $id, 'password' => 'min:5|confirmed:password_confirmation', 'first_name' => 'required', 'last_name' => 'required']);
     if ($validator->passes()) {
         $img_ava = $user->avatar_img;
         $password = Input::get('password');
         if (Input::hasFile('avatar_img')) {
             if (File::exists(Config::get('user.upload_user_ava_directory') . $img_ava)) {
                 File::delete(Config::get('user.upload_user_ava_directory') . $img_ava);
             }
             if (!is_dir(Config::get('user.upload_user_ava_directory'))) {
                 File::makeDirectory(Config::get('user.upload_user_ava_directory'), 0755, true);
             }
             $img = Image::make(Input::file('avatar_img'));
             $img_ava = md5(Input::get('username')) . '.' . Input::file('avatar_img')->getClientOriginalExtension();
             if ($img->width() < $img->height()) {
                 $img->resize(100, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             } else {
                 $img->resize(null, 100, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             }
         }
         $user->update(['username' => null, 'email' => Input::get('email'), 'password' => !empty($password) ? Hash::make($password) : $user->password, 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]);
         return Redirect::back()->with('success_msg', Lang::get('messages.successupdate'));
     } else {
         return Redirect::back()->withErrors($validator)->withInput();
     }
 }
 public function file_move()
 {
     if (Input::hasFile('image')) {
         $vote_id_temp = Session::get('vote_id_insert', '');
         $this->clean($vote_id_temp);
         $file = Input::file('image');
         //
         $fileName = "test222";
         $destinationPath = storage_path() . '/file_import/';
         $file = $file->move($destinationPath, $fileName);
         Excel::selectSheetsByIndex(0)->load($file, function ($reader) use($vote_id_temp) {
             //以第一個資料表中的資料為主
             //提醒使用ooo的使用者,不要存成 Microsoft Excel 95
             //需存成 Microsoft Excel 97/2000/xp  ***.xls
             $value = $reader->get()->toArray();
             //object -> array
             foreach ($value as $data_array1) {
                 //$vote_id_temp = Session::get('vote_id_insert', '');
                 $data_array1['vote_id'] = $vote_id_temp;
                 //var_dump($data_array1);
                 $candidate = Candidate::create($data_array1);
                 // $candidate = new Candidate;
                 // $candidate->cname=$data_array1[0];
                 // $candidate->job_title=$data_array1[1];
                 // $candidate->sex=$data_array1[2];
                 // $candidate->vote_id=42;
                 // $candidate->total_count=0;
                 // $candidate->save();
             }
         });
         // echo $file;
         //File::delete($file);
     }
     return Redirect::route('votes_not_yet');
 }
 public function update($id)
 {
     $rules = array('code' => 'required', 'name' => 'required', 'price' => array('required', 'regex:/^\\d*(\\.\\d{2})?$/'), 'categories' => 'required', 'product_image' => 'mimes:jpeg,bmp,png');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('admin/product/' . $id . '/edit')->withErrors($validator)->withInput();
     } else {
         // store
         $filename = "";
         if (Input::hasFile('product_image')) {
             if (Input::file('product_image')->isValid()) {
                 Input::file('product_image')->move(ProductController::imagePath());
                 $filename = Input::file('product_image')->getClientOriginalName();
             }
         }
         Product::where('code', '=', $id)->update(['code' => Input::get('code')]);
         Product::where('code', '=', $id)->update(['name' => Input::get('name')]);
         if ($filename !== "") {
             Product::where('code', '=', $id)->update(['image' => ProductController::imagePath() . $filename]);
         }
         Product::where('code', '=', $id)->update(['price' => Input::get('price')]);
         $product = Product::where('code', '=', $id)->firstOrFail();
         foreach (Category::all() as $cat) {
             DB::table('products_category')->where('product_id', '=', $product->code)->where('category_id', '=', $cat->id)->softDeletes();
         }
         foreach (Input::get('categories') as $catId) {
             DB::table('products_category')->insert(array('product_id' => $product->code, 'category_id' => $catId));
         }
         // redirect
         Session::flash('message', 'Successfully updated product!');
         return Redirect::to('admin/product');
     }
 }
 /**
  * Store a newly created resource in storage.
  * POST /estudios
  *
  * @return Response
  */
 public function store()
 {
     //check for a file
     if (!Input::hasFile('Filedata')) {
         return 'No file.';
     }
     //nuevo archivo
     $now = Carbon::now();
     $code = $now->timestamp;
     $file = $code . '.' . Input::file('Filedata')->getClientOriginalExtension();
     if (Input::file('Filedata')->move(public_path() . '/media', $file)) {
         $nueva = new Post();
         $nueva->titulo = Input::get('titulo');
         $nueva->tipo = 1;
         $nueva->categoria = 1;
         $nueva->fecha_publicacion = Carbon::now();
         $nueva->attachment = $file;
         $nueva->imagen = '';
         $nueva->subtitulo = '';
         $nueva->descripcion = Input::get('descripcion');
         $nueva->save();
         return '1';
     } else {
         return 'Invalid file type.';
     }
 }
 public function updateProfile()
 {
     $name = Input::get('name');
     //$username = Input::get('username');
     $birthday = Input::get('birthday');
     $bio = Input::get('bio', '');
     $gender = Input::get('gender');
     $mobile_no = Input::get('mobile_no');
     $country = Input::get('country');
     $old_avatar = Input::get('old_avatar');
     /*if(\Cashout\Models\User::where('username',$username)->where('id','!=',Auth::user()->id)->count()>0){
           Session::flash('error_msg', 'Username is already taken by other user . Please enter a new username');
           return Redirect::back()->withInput(Input::all(Input::except(['_token'])));
       }*/
     try {
         $profile = \Cashout\Models\User::findOrFail(Auth::user()->id);
         $profile->name = $name;
         // $profile->username = $username;
         $profile->birthday = $birthday;
         $profile->bio = $bio;
         $profile->gender = $gender;
         $profile->mobile_no = $mobile_no;
         $profile->country = $country;
         $profile->avatar = Input::hasFile('avatar') ? \Cashout\Helpers\Utils::imageUpload(Input::file('avatar'), 'profile') : $old_avatar;
         $profile->save();
         Session::flash('success_msg', 'Profile updated successfully');
         return Redirect::back();
     } catch (\Exception $e) {
         Session::flash('error_msg', 'Unable to update profile');
         return Redirect::back()->withInput(Input::all(Input::except(['_token', 'avatar'])));
     }
 }
示例#21
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $att = new Attachment();
     $att->unguard();
     $att->fill(Input::only('title', 'description', 'hash', 'hash_algorithm', 'public'));
     if (!Input::hasFile('upload')) {
         Session::flash('message', ['content' => 'Geen bestand ontvangen.', 'class' => 'danger']);
         return View::make('attachments.create', ['attachment' => $att]);
     }
     if (!Input::file('upload')->isValid()) {
         Session::flash('message', ['content' => 'Ongeldig bestand ontvangen.', 'class' => 'danger']);
         return View::make('attachments.create', ['attachment' => $att]);
     }
     $file = Input::file('upload');
     $name = $file->getClientOriginalName();
     $extension = $file->getClientOriginalExtension();
     $att->user_id = Auth::user()->id;
     $att->filename = $name;
     $att->extension = $extension;
     // We need to validate the attributes before moving the attachment into place
     if (!$att->validate()) {
         return View::make('attachments.create', ['attachment' => $att])->withErrors($att->validator());
     }
     $file->move($att->folderPath(), $att->filename);
     $att->path = $att->folderPath();
     $att->filesize = filesize($att->fullPath());
     if (in_array($att->extension, Attachment::$image_extensions)) {
         $att->type = 'Image';
     }
     $att->save();
     return Redirect::to(route('attachments.show', [$att->id]))->with('message', ['content' => 'Bestand met succes geupload!', 'class' => 'success']);
 }
 public function update($candidate_id)
 {
     try {
         Log::info(Input::all());
         $candidate = Candidate::findOrFail($candidate_id);
         $candidate->fill(Input::all());
         $user = User::find($candidate->user_id);
         if (\Input::has('skills')) {
             $skills = [];
             foreach (\Input::get('skills') as $skill) {
                 $skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0];
             }
             $user->skills()->detach();
             $user->skills()->sync($skills);
         }
         // Destination path for uplaoded files which is at /public/uploads
         $destinationPath = public_path() . '/uploads/img/';
         // Handle profile Picture
         if (Input::hasFile('profile_pic_filename')) {
             $file = Input::file('profile_pic_filename');
             $profile_pic_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName());
             $uploadSuccess = $file->move($destinationPath, $profile_pic_filename);
             if ($uploadSuccess) {
                 $candidate->profile_pic_filename = $profile_pic_filename;
             }
         }
         $candidate->save();
         $user->candidateProfile->profile_pic_filename = url('/uploads/img/' . $user->candidateProfile->profile_pic_filename);
         $response = $user->candidateProfile;
         $response['skills'] = $user->skills;
         return $this->respondWithArray(['success' => true, 'message' => 'Candidate info updated', 'candidate_profile' => $response]);
     } catch (ModelNotFoundException $e) {
         return $this->setStatusCode(404)->respondWithError('Candidate with ID ' . $candidate_id . ' not found', 404);
     }
 }
示例#23
0
 public function postStore(UsersRequest $request = null, $id = "")
 {
     $input = $request->except('save_continue', 'password_confirmation');
     $result = '';
     if (\Input::hasFile('photo')) {
         $photo = (new \ImageUpload($input))->upload();
     }
     if ($id == "") {
         $input['photo'] = isset($photo) ? $photo : "";
         $input['active'] = $input['active'];
         $input['group_id'] = $input['group_id'];
         $input['created_by'] = \Auth::user()->username;
         $input['password'] = bcrypt($input['password']);
         $query = $this->model->create($input);
         $result = $query->id;
     } else {
         $input['active'] = $input['active'];
         $input['group_id'] = $input['group_id'];
         if (\Input::hasFile('photo')) {
             $input['photo'] = isset($photo) ? $photo : "";
         }
         if (isset($input['password']) && $input['password'] != "") {
             $input['password'] = bcrypt($input['password']);
         }
         $this->model->find($id)->update($input);
         $result = $id;
     }
     $save_continue = \Input::get('save_continue');
     $redirect = empty($save_continue) ? $this->url : $this->url . '/edit/' . $result;
     return redirect($redirect)->with('message', 'Admin saved successfully!');
 }
示例#24
0
 public function editPost($id)
 {
     $user = Auth::user();
     $group = Group::find($id);
     if ($user->id != $group->author->id) {
         return View::make('group.view')->with('group', $group);
     }
     $rules = array('name' => 'required|min:3|max:128', 'description' => 'required', 'file' => 'mimes:jpg,gif,png');
     $logo = '';
     $name = Input::get('name');
     $description = Input::get('description');
     $author_id = Input::get('author_id');
     $tags = Input::get('tags');
     if (Input::hasFile('file')) {
         $file = Input::file('file');
         $ext = $file->guessClientExtension();
         $filename = $file->getClientOriginalName();
         $file->move(public_path() . '/data', md5(date('YmdHis') . $filename) . '.' . $ext);
         $logo = md5(date('YmdHis') . $filename) . '.' . $ext;
     }
     $new_group = array('name' => $name, 'description' => $description, 'author_id' => $author_id, 'views' => 0, 'logo' => $logo, 'tags' => $tags);
     $v = Validator::make($new_group, $rules);
     if ($v->fails()) {
         return Redirect::to('group/add')->with('user', Auth::user())->withErrors($v)->withInput();
     }
     $group->name = $name;
     $group->description = $description;
     $group->author_id = $author_id;
     $group->tags = $tags;
     if (!empty($logo)) {
         $group->logo = $logo;
     }
     $group->save();
     return Redirect::to('group/view/' . $group->id);
 }
示例#25
0
 /**
  * Upload un torrent
  * 
  * @access public
  * @return View torrent.upload
  *
  */
 public function upload()
 {
     $user = Auth::user();
     // Post et fichier upload
     if (Request::isMethod('post')) {
         // No torrent file uploaded OR an Error has occurred
         if (Input::hasFile('torrent') == false) {
             Session::put('message', 'You must provide a torrent for the upload');
             return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
         } else {
             if (Input::file('torrent')->getError() != 0 && Input::file('torrent')->getClientOriginalExtension() != 'torrent') {
                 Session::put('message', 'An error has occurred');
                 return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
             }
         }
         // Deplace et decode le torrent temporairement
         TorrentTools::moveAndDecode(Input::file('torrent'));
         // Array from decoded from torrent
         $decodedTorrent = TorrentTools::$decodedTorrent;
         // Tmp filename
         $fileName = TorrentTools::$fileName;
         // Info sur le torrent
         $info = Bencode::bdecode_getinfo(getcwd() . '/files/torrents/' . $fileName, true);
         // Si l'announce est invalide ou si le tracker et privée
         if ($decodedTorrent['announce'] != route('announce', ['passkey' => $user->passkey]) && Config::get('other.freeleech') == true) {
             Session::put('message', 'Your announce URL is invalid');
             return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
         }
         // Find the right category
         $category = Category::find(Input::get('category_id'));
         // Create the torrent (DB)
         $torrent = new Torrent(['name' => Input::get('name'), 'slug' => Str::slug(Input::get('name')), 'description' => Input::get('description'), 'info_hash' => $info['info_hash'], 'file_name' => $fileName, 'num_file' => $info['info']['filecount'], 'announce' => $decodedTorrent['announce'], 'size' => $info['info']['size'], 'nfo' => Input::hasFile('nfo') ? TorrentTools::getNfo(Input::file('nfo')) : '', 'category_id' => $category->id, 'user_id' => $user->id]);
         // Validation
         $v = Validator::make($torrent->toArray(), $torrent->rules);
         if ($v->fails()) {
             if (file_exists(getcwd() . '/files/torrents/' . $fileName)) {
                 unlink(getcwd() . '/files/torrents/' . $fileName);
             }
             Session::put('message', 'An error has occured may bee this file is already online ?');
         } else {
             // Savegarde le torrent
             $torrent->save();
             // Compte et sauvegarde le nombre de torrent dans  cette catégorie
             $category->num_torrent = Torrent::where('category_id', '=', $category->id)->count();
             $category->save();
             // Sauvegarde les fichiers que contient le torrent
             $fileList = TorrentTools::getTorrentFiles($decodedTorrent);
             foreach ($fileList as $file) {
                 $f = new TorrentFile();
                 $f->name = $file['name'];
                 $f->size = $file['size'];
                 $f->torrent_id = $torrent->id;
                 $f->save();
                 unset($f);
             }
             return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with('message', trans('torrent.your_torrent_is_now_seeding'));
         }
     }
     return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user));
 }
示例#26
0
 public function postRestore()
 {
     // validasi
     $input = Input::all();
     $rules = array('sql' => 'required|sql');
     $validasi = Validator::make(Input::all(), $rules);
     // tidak valid
     if ($validasi->fails()) {
         // pesan
         $sql = $validasi->messages()->first('sql') ?: '';
         return Response::json(compact('sql'));
         // valid
     } else {
         // ada sql
         if (Input::hasFile('sql')) {
             // nama sql
             $sql = date('dmYHis') . '.sql';
             // unggah sql ke dir "app/storage/restores"
             Input::file('sql')->move(storage_path() . '/restores/', $sql);
             // path file
             $file = storage_path() . '/restores/' . $sql;
             // dump database
             $dump = new Dump();
             $dump->file($file)->dsn($this->dsn)->user($this->user)->pass($this->pass);
             new Import($dump);
             // hapus file restore
             unlink($file);
             // tidak ada sql
         } else {
             // pesan
             $sql = 'Sql gagal diunggah.';
             return Response::json(compact('sql'));
         }
     }
 }
示例#27
0
 public function updateWelcomeMessage()
 {
     $user = User::find(Auth::user()->id);
     $data = array('welcome_message' => Input::get('welcome_message'), 'welcome_phone_number' => Input::get('welcome_phone_number'));
     $customRule['welcome_message'] = 'required';
     $customRule['welcome_phone_number'] = 'required';
     $messages = array('required' => 'Harap mengisi informasi :attribute.', 'image' => 'Tipe file gambar yang Anda berikan salah, mohon mencoba kembali.');
     $validator = Validator::make($data, $customRule, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if (Input::hasFile('welcome_photo')) {
         // checking file is valid.
         if (Input::file('welcome_photo')->isValid()) {
             $destinationPath = '/uploads/anggota';
             // upload path
             $extension = Input::file('welcome_photo')->getClientOriginalExtension();
             // getting image extension
             $fileName = $user->id . '.' . $extension;
             // rename image
             Input::file('welcome_photo')->move(public_path() . $destinationPath, $fileName);
             // uploading file to given path
             $data['welcome_photo'] = $destinationPath . "/" . $fileName;
         } else {
             // sending back with error message.
             return Redirect::back()->with('errors', 'Uploaded file is not valid')->withInput();
         }
     }
     $user->update($data);
     return Redirect::route('member.dashboard')->with("message", "Data berhasil disimpan");
 }
示例#28
0
文件: Post.php 项目: doptor/doptor
 /**
  * Upload the image while creating/updating records
  * @param File Object $file
  */
 public function setImageAttribute($file)
 {
     // Only if a file is selected
     if ($file) {
         if (Input::hasFile('image')) {
             // If an actual file is selected
             File::exists(public_path() . '/uploads/') || File::makeDirectory(public_path() . '/uploads/');
             File::exists(public_path() . '/' . $this->images_path) || File::makeDirectory(public_path() . '/' . $this->images_path);
             File::exists(public_path() . '/' . $this->thumbs_path) || File::makeDirectory(public_path() . '/' . $this->thumbs_path);
             $file_name = $file->getClientOriginalName();
             $image = Image::make($file->getRealPath());
             if (isset($this->attributes['image'])) {
                 // Delete old image
                 $old_image = $this->getImageAttribute();
                 File::exists($old_image) && File::delete($old_image);
             }
             if (isset($this->attributes['thumb'])) {
                 // Delete old thumbnail
                 $old_thumb = $this->getThumbAttribute();
                 File::exists($old_thumb) && File::delete($old_thumb);
             }
             $image->save($this->images_path . $file_name)->fit(640, 180)->save($this->thumbs_path . $file_name);
             $file_name = $this->images_path . $file_name;
         } else {
             // If the input is not a file, save the filename received instead
             $file_name = $file;
         }
         $this->attributes['image'] = $file_name;
     }
 }
 /**
  * Upload the file and store
  * the file path in the DB.
  */
 public function store()
 {
     // Rules
     $rules = array('name' => 'required', 'file' => 'required|max:20000');
     $messages = array('max' => 'Please make sure the file size is not larger then 20MB');
     // Create validation
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $directory = "uploads/files/";
     // Before anything let's make sure a file was uploaded
     if (Input::hasFile('file') && Request::file('file')->isValid()) {
         $current_file = Input::file('file');
         $filename = Auth::id() . '_' . $current_file->getClientOriginalName();
         $current_file->move($directory, $filename);
         $file = new Upload();
         $file->user_id = Auth::id();
         $file->project_id = Input::get('project_id');
         $file->name = Input::get('name');
         $file->path = $directory . $filename;
         $file->save();
         return Redirect::back();
     }
     $upload = new Upload();
     $upload->user_id = Auth::id();
     $upload->project_id = Input::get('project_id');
     $upload->name = Input::get('name');
     $upload->path = $directory . $filename;
     $upload->save();
     return Redirect::back();
 }
 public function postProfil()
 {
     $validate = Validator::make(Input::all(), ['adsoyad' => 'required', 'email' => 'required|email|unique:users,email,' . Auth::user()->id . '', 'profil' => 'mimes:jpg,png,gif,jpeg']);
     $messages = $validate->messages();
     if ($validate->fails()) {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Doğrulama Hatası', 'text' => '' . $messages->first() . '', 'type' => 'error'));
     }
     $user = User::findOrFail(Auth::user()->id);
     $user->namesurname = Input::get('adsoyad');
     if (Input::has('password')) {
         $user->password = Hash::make(Input::get('password'));
         $user->save();
     }
     $user->email = Input::get('email');
     if (Input::hasFile('profil')) {
         if (Auth::user()->profil != '') {
             File::delete('Backend/avatar/' . Auth::user()->profil . '');
         }
         $profil = Input::file('profil');
         $dosyaadi = $profil->getClientOriginalName();
         $uzanti = $profil->getClientOriginalExtension();
         $isim = Str::slug($dosyaadi) . Str::slug(str_random(5)) . '.' . $uzanti;
         $dosya = $profil->move('Backend/avatar/', $isim);
         $image = Image::open('Backend/avatar/' . $isim)->resize(80, 80)->save();
         $user->profil = $isim;
         $user->save();
     }
     $user->save();
     if ($user->save()) {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Güncellendi', 'text' => 'Kullanıcı Başarı İle Güncellendi', 'type' => 'success'));
     } else {
         return Redirect::back()->with(array('mesaj' => 'true', 'title' => 'Kullanıcı Güncellenemedi', 'text' => 'Kullanıcı Güncellenirken Sorun İle Karşılaşıldı', 'type' => 'error'));
     }
 }