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); }
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 postUpdate($id) { $archivo = Input::file('archivo'); $imagen = Input::file('imagen'); $validator = Validator::make(array('archivo' => $archivo, 'imagen' => $imagen), array('archivo' => 'mimes:png,jpeg,gif,txt,ppt,pdf,doc,xls', 'imagen' => 'mimes:png,jpeg,gif'), array('mimes' => 'Tipo de archivo inválido, solo se admite los formatos PNG, JPEG, y GIF')); if ($validator->fails()) { return Redirect::to($this->route . '/create')->with('msg_err', Lang::get('messages.companies_create_img_err')); } else { $arquivo = SFArquivos::find($id); $arquivo->titulo_archivo = Input::get('titulo_archivo'); $arquivo->id_categoria = Input::get('id_categoria'); $arquivo->resumem = Input::get('resumem'); $arquivo->tipo_archivo = Input::get('tipo_archivo'); if ($archivo != "") { $url = $archivo->getRealPath(); $extension = $archivo->getClientOriginalExtension(); $name = str_replace(' ', '', strtolower(Input::get('titulo_archivo'))) . date('YmdHis') . rand(2, 500 * 287) . '.' . $extension; $size = $archivo->getSize(); $mime = $archivo->getMimeType(); $archivo->move(public_path('uploads/arquivos/'), $name); $arquivo->archivo = $name; } if ($imagen != "") { $imagen = $this->uploadHeader($imagen); $arquivo->imagen = $imagen; } $arquivo->save(); return Redirect::to($this->route)->with('msg_success', Lang::get('messages.companies_create', array('title' => $arquivo->title))); } }
/** * 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)); }
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']))); } }
public function update($id) { $validator = Validator::make(array('slider' => Input::file('slider')), array("slider" => "image | mimes:jpeg, jpg, png, gif | max: 6000"), array('mimes' => '<span class="glyphicon glyphicon-remove"></span> Unknown file inserted', 'size' => '<span class="glyphicon glyphicon-exclamation-sign"></span> Size must be less than 6 MB')); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { if (Input::file('slider') != '') { $file = Input::file('slider'); $name = date('i-G-Y') . $file->getClientOriginalName(); $destination = 'assets/images/slider/'; $file->move($destination, $name); $query = Slider::find($id); $query->slider = 'assets/images/slider/' . $name; $query->slider_text = Input::get('text'); if ($query->save()) { return Redirect::route('slider-page')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Slider updated successfully</p>'); } else { return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured. Please try after sometime</p>'); } } else { $query = Slider::find($id); $query->slider_text = Input::get('text'); if ($query->save()) { return Redirect::route('slider-page')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Slider updated successfully</p>'); } else { return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured. Please try after sometime</p>'); } } } }
/** * 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(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $file = array('image' => Input::file('image')); // setting up rules $rules = array('image' => 'required|mimes:jpeg,gif'); // doing the validation, passing post data, rules and the messages $validator = Validator::make($file, $rules); // process the login if ($validator->fails()) { return Redirect::to('images/create')->withErrors($validator)->withInput(Input::except('password')); } else { // store // $userId = Auth::user()->id; // $file = Input::file('image'); // $data = Img::make($file)->encode('data-url'); // // $this->image->user_id = $userId; // $this->image->img_name = $data->encoded; // $this->image->save(); $file = Input::file('image'); $picture = $file->getClientOriginalName(); $generatepic = rand(32321323, 8687868678) . $picture; $fullpath = $file->move('../public/img', $generatepic); $images = new Images(); $images->image = $fullpath; // $images->image = Input::file('image')->getClientOriginalName(); $images->save(); // redirect Session::flash('message', 'Successfully uploaded!'); return Redirect::to('images'); } }
/** * Stores new account * * @return Illuminate\Http\Response */ public function store() { $repo = App::make('UserRepository'); $user = $repo->signup(Input::all()); if ($user->id) { if (Config::get('confide::signup_email')) { Mail::queueOn(Config::get('confide::email_queue'), Config::get('confide::email_account_confirmation'), compact('user'), function ($message) use($user) { $message->to($user->email, $user->first_name)->subject(Lang::get('confide::confide.email.account_confirmation.subject')); }); } return Redirect::action('UsersController@login')->with('notice', Lang::get('confide::confide.alerts.account_created')); } else { $error = $user->errors()->all(':message'); return Redirect::action('UsersController@create')->withInput(Input::except('password'))->with('error', $error); } $input = array('image' => Input::file('image')); $rules = array('image' => 'image'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($e->getErrors()); } else { $file = Input::file('image'); $name = time() . '-' . $file->getClientOriginalName(); $file = $file->move('uploads/', $name); $input['file'] = '/public/uploads/' . $name; } }
/** * 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.'; } }
/** * Store a newly created resource in storage. * * @return Response * @throws ImageFailedException * @throws \BB\Exceptions\FormValidationException */ public function store() { $data = \Request::only(['user_id', 'category', 'description', 'amount', 'expense_date', 'file']); $this->expenseValidator->validate($data); if (\Input::file('file')) { try { $filePath = \Input::file('file')->getRealPath(); $ext = \Input::file('file')->guessClientExtension(); $mimeType = \Input::file('file')->getMimeType(); $newFilename = \App::environment() . '/expenses/' . str_random() . '.' . $ext; Storage::put($newFilename, file_get_contents($filePath), 'public'); $data['file'] = $newFilename; } catch (\Exception $e) { \Log::error($e); throw new ImageFailedException($e->getMessage()); } } //Reformat from d/m/y to YYYY-MM-DD $data['expense_date'] = Carbon::createFromFormat('j/n/y', $data['expense_date']); if ($data['user_id'] != \Auth::user()->id) { throw new \BB\Exceptions\FormValidationException('You can only submit expenses for yourself', new \Illuminate\Support\MessageBag(['general' => 'You can only submit expenses for yourself'])); } $expense = $this->expenseRepository->create($data); event(new NewExpenseSubmitted($expense)); return \Response::json($expense, 201); }
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 upload() { $file = Input::file('file'); $input = array('image' => $file); $rules = array('image' => 'image'); $validator = Validator::make($input, $rules); $imagePath = 'public/uploads/'; $thumbPath = 'public/uploads/thumbs/'; $origFilename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $mimetype = $file->getMimeType(); if (!in_array($extension, $this->whitelist)) { return Response::json('Supported extensions: jpg, jpeg, gif, png', 400); } if (!in_array($mimetype, $this->mimeWhitelist) || $validator->fails()) { return Response::json('Error: this is not an image', 400); } $filename = str_random(12) . '.' . $extension; $image = ImageKit::make($file); //save the original sized image for displaying when clicked on $image->save($imagePath . $filename); // make the thumbnail for displaying on the page $image->fit(640, 480)->save($thumbPath . 'thumb-' . $filename); if ($image) { $dbimage = new Image(); $dbimage->thumbnail = 'uploads/thumbs/thumb-' . $filename; $dbimage->image = 'uploads/' . $filename; $dbimage->original_filename = $origFilename; $dbimage->save(); return $dbimage; } else { return Response::json('error', 400); } }
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"); } }
/** * 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!'); }
public function update($id) { $data = Input::all(); $avatar = Input::file('avatar'); if (FEUsersHelper::isCurrentUser($id)) { $validator = FEUsersHelper::validateUpdateInfo(); if ($validator->fails()) { $messages = $validator->messages(); $errors = json_encode($messages); echo $errors; } else { $user = Users::where('account', $data['account'])->first(); $user['fullname'] = $data['fullname']; $user['email'] = $data['email']; $user['phone'] = $data['phone']; $user['address'] = $data['address']; $user['about'] = $data['about']; if ($avatar) { $upload_avatar_folder = 'avatar/' . $user->account . "/"; $name = $avatar->getFilename() . uniqid() . "." . $avatar->getClientOriginalExtension(); $avatar->move(public_path() . "/" . $upload_avatar_folder, $name); $user->avatar = 'public/' . $upload_avatar_folder . $name; } $user->save(); Session::flush('user'); Session::put('user', $user); echo json_encode('success'); } } else { echo json_encode('fail'); } // return false; }
public function Insert_UpdateNews($data) { $id = Input::get("id"); if (!Input::has('id')) { $news = new News(); } else { $news = News::find(array_get($data, 'id')); //tìm id đã có trong data } $news->title = array_get($data, 'title'); // Upload images if (Input::file('file')) { define('PATH_CATEGORY_ICON', rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/upload/'); $file = array_get($data, 'file'); $file->move(PATH_CATEGORY_ICON, $file->getClientOriginalName()); $news->images = $file->getClientOriginalName(); } // End Upload images $news->tomtat = array_get($data, 'tomtat'); $news->content = array_get($data, 'content'); $news->cat_id = array_get($data, 'cat_id'); $news->hot = array_get($data, 'hot'); $news->ngaydangbai = date('Y-m-d H:i:s'); return $news->save(); }
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); } }
public function actualizarMisionVision() { $response = 0; $id_centro = e(Input::get('id_centro')); $mision_centro = e(Input::get('mision_centro')); $vision_centro = e(Input::get('vision_centro')); $quienes_somos_centro = e(Input::get('quienes_somos_centro')); $centro = Centro::buscar_centro($id_centro); if (!is_null(Input::file('img_centro'))) { $file_img_vieja = $centro->img_centro; $file_img_centro = Input::file('img_centro'); $img_centro = $file_img_centro->getClientOriginalName(); } else { $img_centro = $centro->img_centro; } $response = Centro::actualizar_centro_mision_vision_quienes($id_centro, $mision_centro, $vision_centro, $quienes_somos_centro, $img_centro); if ($response == 1) { if (!is_null(Input::file('img_centro'))) { $file_img_centro->move('img', $file_img_centro->getClientOriginalName()); File::delete('img/' . $file_img_vieja); } return Redirect::to(URL::previous())->with('mensaje', 'Centro de Investigacion Actualizado Insertado Correctamente'); } else { return Redirect::to(URL::previous())->with('mensaje', 'Ha ocurrido un error'); } }
public function registrarProfesor() { $new_profesor = new Profesor(); $new_profesor->num_empleado = Input::get("num_empleado"); $new_profesor->password = Input::get("password"); $new_profesor->email = Input::get("email"); $new_datos_profesor = new DatosProfesor(); $new_datos_profesor->nombre = Input::get("nombre"); $new_datos_profesor->apellido_paterno = Input::get("apellido_paterno"); $new_datos_profesor->apellido_materno = Input::get("apellido_materno"); $new_datos_profesor->sexo = Input::get("sexo"); $new_datos_profesor->celular = Input::get("celular"); // Pequeño hack. Primero lo ponemos como archivo para validarlo, después le asignamos la ruta real para guardarlo $new_datos_profesor->ruta = Input::file('cv'); if ($new_profesor->validate()) { if ($new_datos_profesor->validate()) { $nombreCV = Input::get("nombre") . "_" . Input::get("apellido_paterno") . "_" . Input::get("apellido_materno") . "_CV.pdf"; //CHECAR PORQUE NO SE CREA EL PUTO CV!!! Input::file('cv')->move("CVs", $nombreCV); $new_datos_profesor->ruta = "/CVs/" . $nombreCV; //Ahora si, guardamos todo después de haberlo validado $new_profesor->save(); $new_datos_profesor->profesor()->associate($new_profesor); // Forzamos Save porque sabemos que no validará ruta como un string, sino como un file $new_datos_profesor->forceSave(); return Redirect::to('/'); } else { return Redirect::route('registro')->withErrors($new_datos_profesor->errors())->withInput(); } } else { $new_datos_profesor->validate(); $erroresValidaciones = array_merge_recursive($new_profesor->errors()->toArray(), $new_datos_profesor->errors()->toArray()); return Redirect::route('registro')->withErrors($erroresValidaciones)->withInput(); } }
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 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')); } } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); if ($this->post->fill($input)->validate_post()) { $image = Input::file('attachment'); if ($image->isValid()) { $path = 'uploads/posts/' . Auth::user()->username; $filename = 'posts-' . time() . rand(1000, 9999) . '.' . $image->getClientOriginalExtension(); if ($image->move($path, $filename)) { $data = $this->post->create(['user_id' => Auth::user()->id, 'title' => $input['title'], 'content' => $input['content'], 'attachment' => $filename]); if ($data->id) { $post = $this->post->find($data->id); $post->tags()->attach($input['tags']); Session::flash('type', 'success'); Session::flash('message', 'Post Created'); return Redirect::route('post.index'); } else { Session::flash('type', 'error'); Session::flash('message', 'Error!!! Cannot create post'); return Redirect::back()->withInput(); } } else { Session::flash('type', 'error'); Session::flash('message', 'Error!!! File cannot be uploaded'); return Redirect::back()->withInput(); } } else { Session::flash('type', 'error'); Session::flash('message', 'Error!!! File is not valid'); return Redirect::back()->withInput(); } } else { return Redirect::back()->withInput()->withErrors($this->post->errors); } }
/** * 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 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"); }
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'); }
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.'); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $familia = Familia::findOrFail($id); $validator = Familia::validator(Input::all()); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $datos = Input::all(); if (Input::file('foto')) { $file = Input::file('foto'); $destinationPath = 'uploads/images/'; $filename = Str::random(20) . '.' . $file->getClientOriginalExtension(); $mimeType = $file->getMimeType(); $extension = $file->getClientOriginalExtension(); $upload_success = $file->move($destinationPath, $filename); if ($familia->foto != 'fam.jpg') { File::delete($destinationPath . $familia->foto); } $datos['foto'] = $filename; } else { unset($datos['foto']); } $familia->update($datos); Session::flash('message', 'Actualizado Correctamente'); Session::flash('class', 'success'); return Redirect::to('/dashboard/familia'); }
public static function addMedia($fileName, $objType, $user_id, $route) { $file = Input::file($fileName); $currentMo = date('Y_M'); $destination = "uploads/{$currentMo}"; $filename = $file->getClientOriginalName(); $filename = Exhibit::string_convert($filename); // $cleanFilename = Exhibit::permalink($filename); // Move the new file into the uploads directory $uploadSuccess = $file->move($destination, "{$filename}"); $imgOrigDestination = $destination . '/' . $filename; // Check to make sure that upload was successful and add the content if ($uploadSuccess) { $imageMinDestination = $destination . '/min_' . $filename; $imageMin = Image::make($imgOrigDestination)->crop(250, 250, 10, 10)->save($imageMinDestination); // Saves the media and adds the appropriate foreign keys for the exhibit $media = $objType->media()->create(['user_id' => $user_id, 'img_min' => $imageMinDestination, 'img_big' => $imgOrigDestination]); $objType->media()->save($media); return $media->id; } else { if ($route == 'back') { return Redirect::back()->with('status', 'alert-error')->with('global', 'Something went wrong with uploading your photos.'); } return Redirect::route($route)->with('status', 'alert-error')->with('global', 'Something went wrong with uploading your photos.'); } }
public function postUpload() { $file = Input::file($this->input_name); $rstring = str_random(15); $destinationPath = realpath($this->upload_dir) . '/' . $rstring; $filename = $file->getClientOriginalName(); $filemime = $file->getMimeType(); $filesize = $file->getSize(); $extension = $file->getClientOriginalExtension(); //if you need extension of the file $filename = str_replace(Config::get('kickstart.invalidchars'), '-', $filename); $uploadSuccess = $file->move($destinationPath, $filename); $sheets = Excel::load($destinationPath . '/' . $filename)->calculate()->toArray(); $newsheets = array(); foreach ($sheets as $name => $sheet) { $newrows = array(); foreach ($sheet as $row) { if (implode('', $row) != '') { $rstr = str_random(5); $newrows[$rstr] = $row; } } $newsheets[$name] = $newrows; } file_put_contents(realpath($this->upload_dir) . '/' . $rstring . '.json', json_encode($newsheets)); return Redirect::to(strtolower($this->controller_name) . '/preview/' . $rstring); }