示例#1
1
 public function post_nuevo()
 {
     $inputs = Input::all();
     $reglas = array('localidad' => 'required|max:50');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $localidad = new Localidad();
         $localidad->localidad = Input::get('localidad');
         $localidad->save();
         return Redirect::to('lista_localidades')->with('error', 'La Localidad ha sido registrada con Éxito')->withInput();
     }
 }
示例#2
0
 public function update()
 {
     $inputs = Input::all();
     $reglas = array('sucursal' => 'required', 'stock' => 'required|integer');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $id_articulo = Input::get('id_articulo');
         $id_sucursal = Input::get('sucursal');
         $stock = Input::get('stock');
         $p = DB::table('stock')->where('id_articulo', $id_articulo)->where('id_sucursal', $id_sucursal)->first();
         if (empty($p)) {
             DB::table('stock')->insert(array('id_articulo' => $id_articulo, 'id_sucursal' => $id_sucursal, 'cantidad' => $stock));
         } else {
             DB::table('stock')->where('id_articulo', $id_articulo)->where('id_sucursal', $id_sucursal)->update(array('cantidad' => $stock));
         }
         $sucursales = Sucursal::all();
         $articulo_id = $id_articulo;
         $articulos = DB::table('articulos')->join('stock', 'articulos.id_articulo', '=', 'stock.id_articulo')->join('sucursales', 'stock.id_sucursal', '=', 'sucursales.id_sucursal')->select('articulos.id_articulo', 'articulos.nombre', 'sucursales.nombre as sucursal', 'stock.cantidad')->get();
         return View::make('edit_stock')->with('ok', 'El Stock se ha actualizado con éxito')->with('sucursales', $sucursales)->with('articulo_id', $articulo_id)->with('articulos', $articulos);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  NA
  * @return NA
  */
 public function requestLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('user_email' => 'required|email', 'password' => 'required|min:4');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to(URL::previous())->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $user_array = array('user_email' => $this->getInput('user_email', ''), 'password' => $this->getInput('password', ''));
         // attempt to do the login
         if (Auth::attempt($user_array)) {
             $current_password = $this->getInput('password', '');
             // additional validation to make sure that password matched
             $user = Auth::user();
             if (Hash::check($current_password, $user->password)) {
                 return Redirect::intended('check');
             }
         } else {
             Input::flash();
             Session::flash('error_message', 'Invalid email or password, please try again');
             $this->data['has_error'] = ERROR;
             return View::make('session.login')->with('data', $this->data);
         }
     }
 }
示例#4
0
 public function post_edit()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('comments')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     $id = Input::get('editingMode');
     $editComment = Comment::find($id);
     $editComment->name = Input::get('name');
     $editComment->email = Input::get('email');
     $editComment->content = Input::get('content');
     //Add rules here
     $rules = array('name' => 'required', 'email' => 'required', 'content' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to($_SERVER['PATH_INFO'] . '?id=' . $editComment->id)->with_errors($validation);
     }
     //Update the comment
     $editComment->save();
     return Redirect::to($_SERVER['PATH_INFO'] . '?id=' . $editComment->id)->with('successmessage', 'Comment successfully updated');
 }
 public function crearProyecto()
 {
     $data = Input::all();
     $ciclo = $data['cicle'];
     $ciclo == 1 ? $ciclo = 'Agosto-Enero' : ($ciclo = 'Enero-Julio');
     //Valida los datos ingresados.
     $notificaciones = ['year.required' => '¡Escriba un año!', 'year.numeric' => '¡El año debe ser numérico!'];
     $validation = Validator::make($data, ['year' => 'required|numeric'], $notificaciones);
     if ($validation->passes()) {
         //Se revisa si había registros antes
         $temp = Proyecto::select('ciclo', 'anio')->where('ciclo', $ciclo)->where('anio', $data['year'])->get();
         //Si aún no había registros, se añaden las horas disponbiles por aula y día.
         if (sizeof($temp) < 1) {
             $idProyecto = Proyecto::insertGetId(['ciclo' => $ciclo, 'anio' => $data['year']]);
             $aulas = Aula::count();
             $horas = Hora::select('*')->where('id', '>', '0')->get();
             for ($i = 2; $i <= $aulas; $i++) {
                 for ($k = 0; $k < 5; $k++) {
                     foreach ($horas as $hora) {
                         $temp = new Disponible();
                         $temp->id_aula = $i;
                         $temp->hora = $hora['id'];
                         $temp->dia = $k;
                         $temp->id_proyecto = $idProyecto;
                         $temp->save();
                     }
                 }
             }
         }
         return Redirect::to('/proyectos/');
     } else {
         Input::flash();
         return Redirect::to('/proyectos/editar-proyecto')->withInput()->withErrors($validation);
     }
 }
 public function update()
 {
     $validator = Validator::make(Input::all(), array('schoolname' => 'required|min:3|max:256', 'schoolnameabbr' => 'required|alpha|min:2|max:10', 'schooladdress' => 'required|min:4|max:512', 'logo' => 'required', 'adminsitename' => 'required|min:2|max:256', 'systemurl' => 'required|url', 'url' => 'url|required', 'cache' => "required|integer"));
     if ($validator->fails()) {
         Input::flash();
         return Redirect::to('/settings')->withErrors($validator);
     }
     $schoolname = Input::get('schoolname');
     Setting::set('system.schoolname', $schoolname);
     Setting::set('system.schoolnameabbr', Input::get('schoolnameabbr'));
     Setting::set('system.schooladdress', Input::get('schooladdress'));
     Setting::set('system.logo_src', Input::get('logo'));
     Setting::set('system.adminsitename', Input::get('adminsitename'));
     Setting::set('app.url', Input::get('url'));
     Setting::set('app.captcha', Input::get('captcha'));
     Setting::set('system.dashurl', Input::get('systemurl'));
     Setting::set('system.dashurlshort', Input::get('systemurlshort'));
     Setting::set('system.siteurlshort', Input::get('siteurlshort'));
     Setting::set('system.cache', Input::get('cache'));
     $theme = Theme::uses('dashboard')->layout('default');
     $view = array('name' => 'Dashboard Settings');
     $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Dashboard', 'url' => Setting::get('system.dashurl') . '/settings']]);
     $theme->appendTitle(' - Settings');
     return $theme->scope('settings', $view)->render();
 }
 public function update($dash, $id)
 {
     if ($id == 0) {
         $validator = Validator::make(Input::all(), array('title' => 'required|min:3|max:256', 'description' => 'max:1024', 'tutorial' => 'required'));
         $messages = array('required' => 'The :attribute field is required.');
         if ($validator->fails()) {
             Input::flash();
             return Redirect::to('tutorial/edit/' . $id)->withErrors($validator)->with('input', Input::get('published'));
         } else {
             if (Sentry::getUser()->inGroup(Sentry::findGroupByName('teachers'))) {
                 $newid = self::createtutorial($id);
                 Cache::forget("tutorial_listing_dash" . Sentry::getUser()->id);
                 return Redirect::to('/tutorial/edit/' . $newid . '');
             }
             Input::flash();
             // Log::error(Input::get('subject'));
             return Redirect::to('/tutorial/edit/' . $id . '');
         }
     } else {
         $validator = Validator::make(Input::all(), array('title' => 'required|min:3|max:256', 'description' => 'required|max:1024', 'tutorial' => 'required'));
         $messages = array('required' => 'The :attribute field is required.');
         if ($validator->fails()) {
             Input::flash();
             return Redirect::to('/tutorial/edit/' . $id . '')->withErrors($validator);
         } else {
             $tutorialcheck = Tutorials::find($id);
             if ($tutorialcheck->createdby == Sentry::getUser()->id || Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) {
                 self::updatetutorial($id);
                 return Redirect::to('/tutorial/edit/' . $id . '');
             }
             return Redirect::to("/");
         }
     }
 }
示例#8
0
 public function search()
 {
     $query_supplier = '%' . Input::get('supplier') . '%';
     $query_metal = '%' . Input::get('metal') . '%';
     $query_city = '%' . Input::get('city') . '%';
     $query_grade_a = '%' . Input::get('grade_a') . '%';
     $query_grade_b = '%' . Input::get('grade_b') . '%';
     $query_thickness = '%' . Input::get('thickness') . '%';
     $query_shape = '%' . Input::get('shape') . '%';
     if (Input::has('volume_from')) {
         $query_volume_from = Input::get('volume_from');
     } else {
         $query_volume_from = 0;
     }
     if (Input::has('volume_to')) {
         $query_volume_to = Input::get('volume_to');
     } else {
         $query_volume_to = Product::max('volume');
     }
     if (Input::has('date_from')) {
         $query_date_from = date('Y-m-d H:i:s', strtotime(Input::get('date_from')));
     } else {
         $query_date_from = date('Y-m-d H:i:s', strtotime("1-1-1970"));
     }
     if (Input::has('date_to')) {
         $query_date_to = date('Y-m-d H:i:s', strtotime(Input::get('date_to') . " 23:59"));
     } else {
         $query_date_to = date('Y-m-d H:i:s', strtotime("now"));
     }
     $products = Product::where('supplier', 'LIKE', $query_supplier)->where('metal', 'LIKE', $query_metal)->where('city', 'LIKE', $query_city)->where('grade_a', 'LIKE', $query_grade_a)->where('grade_b', 'LIKE', $query_grade_b)->where('thickness', 'LIKE', $query_thickness)->where('shape', 'LIKE', $query_shape)->whereBetween('created_at', array($query_date_from, $query_date_to))->whereBetween('volume', array($query_volume_from, $query_volume_to))->paginate(5);
     $suppliers = Product::lists('supplier', 'supplier');
     $metals = Product::lists('metal', 'metal');
     return View::make('products.list')->with('products', $products)->with('suppliers', $suppliers)->with('metals', $metals)->withInput(Input::flash());
 }
 public function addTask()
 {
     if ($_POST) {
         // Lets start validation
         // validate input
         $rules = array('name' => 'required|max:50', 'description' => 'required', 'didyouknow' => 'required', 'reference' => 'required');
         $validation = Validator::make(Input::all(), $rules);
         if ($validation->fails()) {
             Input::flash();
             return Redirect::back()->withInput()->withErrors($validation);
         }
         $task = new Task();
         $task->name = Input::get('name');
         $task->description = Input::get('description');
         $task->didyouknow = Input::get('didyouknow');
         $task->reference = Input::get('reference');
         $task->author = Input::get('taskauthor');
         $task->createdby = 0;
         $task->suspended = 0;
         $task->number = 0;
         $task->save();
         return Redirect::to('tasks/manage');
     }
     return View::make('task.add');
 }
示例#10
0
 public function validate($input = null, $rules = null, $messages = null)
 {
     if (is_null($input)) {
         $input = Input::all();
     }
     if (is_null($rules)) {
         $rules = $this->getRules();
     }
     if (is_null($messages)) {
         $messages = $this->getMessages();
     }
     $v = Validator::make($input, $rules, $messages);
     if ($v->passes()) {
         return true;
     } else {
         Input::flash();
         foreach ($input as $key => $value) {
             $error = $v->messages()->get($key);
             if ($error) {
                 $this->validationMessages[$key] = $error;
             }
         }
         $this->error = $v->errors();
         return false;
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     if (\Input::get('month')) {
         $data = \Input::all();
         $date = $data['year'] . '-' . $data['month'] . '-01';
         $emp_type = $data['emp_type'];
         $client = \Input::get('clientId');
         $payType = \Input::get('payType');
         $empId = \Input::get('empId');
         if ($emp_type == 'inhouse') {
             $uId = \Auth::user()->id;
             $emp = \User::whereHas('empJobDetail', function ($q) use($uId, $date) {
                 $q->where('emp_type', '=', 'inhouse');
                 $q->whereHas('branch', function ($s) use($uId) {
                     $s->where('branch_id', '=', $uId);
                 });
                 $q->whereHas('attend', function ($a) use($date) {
                     $a->where('attend_date', '=', $date);
                 });
             })->paginate(20);
         } elseif ($emp_type == 'outsource' && $client != '') {
             $emp = \User::whereHas('empJobDetail', function ($q) use($client, $date) {
                 $q->whereHas('attend', function ($a) use($date) {
                     $a->where('attend_date', '=', $date);
                 });
                 $q->where('emp_type', '=', 'outsource');
                 $q->where('client_id', '=', $client);
             })->paginate(20);
         }
         return \View::make('branch/salary.manage_salary')->with('emp', $emp)->with('date', $date)->with(\Input::flash());
     } else {
         return \View::make('branch/salary.manage_salary');
     }
 }
示例#12
0
 public function NuevaTarea()
 {
     $enviado = Input::get('enviado');
     if (isset($enviado)) {
         $rules = $this->getRulesNuevaTarea();
         $messages = $this->getMensajesNuevaTarea();
         $validator = Validator::make(Input::All(), $rules, $messages);
         if ($validator->passes()) {
             $insert = $this->InsertarTarea(Input::all());
             if ($insert === 1) {
                 $mensaje = 'Tarea Creada con Éxito';
                 $visible = false;
             } else {
             }
             return Redirect::route('listatareas')->withInput(Input::flash());
         } else {
             Session::flash('visibleNuevo', TRUE);
             return Redirect::route('listatareas')->withInput(Input::flash())->withErrors($validator);
         }
     } else {
         Session::flash('mensajeError', $mensajeError);
         Session::flash('visibleNuevo', TRUE);
         return Redirect::route('listatareas');
     }
 }
示例#13
0
 public function update()
 {
     $inputs = Input::all();
     $reglas = array('first_name' => 'required|min:4', 'last_name' => 'required', 'email' => 'email', 'username' => 'required', 'password' => 'required|min:5|max:20', 'confirmar_clave' => 'required|same:password');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $id_user = Input::get('id');
         $user = User::find($id_user);
         $clave = Input::get('password');
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->email = Input::get('email');
         $user->username = Input::get('username');
         $user->password = Hash::make($clave);
         $user->tipo_usuario = Input::get('tipo_usuario');
         $user->save();
         return Redirect::to('lista_usuarios')->with('error', 'El usuario ha sido actualizado con Éxito')->withInput();
         //$users = User::all();
         //return View::make('lista_usuarios')->with('users', $users);
     }
 }
示例#14
0
 public function action_index($modelName)
 {
     $model = $this->getClassObject($modelName);
     $columnModel = $model::first();
     Input::flash();
     if (Input::get($modelName) != null && $this->addConditions($model, $modelName)->first() != null) {
         $columnModel = $this->addConditions($model, $modelName)->first();
     }
     if ($columnModel == null) {
         return Redirect::to("/lara_admin/models/{$modelName}/new");
     }
     $columns = $columnModel->columns();
     $sort_options = $this->setOrderOptions($columns);
     $models = $this->addConditions($model, $modelName)->order_by($sort_options["column_order"], $sort_options["sort_direction"])->paginate($model->perPage);
     $request_uri = Request::server("REQUEST_URI");
     $request_uri = preg_replace("/&order=[^&]*/", "", $request_uri);
     if (!preg_match("/\\?/i", Request::server("REQUEST_URI"))) {
         $request_uri .= "?";
     }
     //TODO function getCustomAction
     $name_custom_action = "lara_admin::" . Str::plural(Str::lower($modelName)) . "." . preg_replace("/action_/", "", __FUNCTION__);
     if (View::exists($name_custom_action) != false) {
         $view = View::make($name_custom_action, array("sort_options" => $sort_options, "request_uri" => $request_uri, "modelName" => $modelName, "modelInstance" => $model, "models" => $models, "columns" => $columns));
     } else {
         $view = View::make("lara_admin::models.index", array("sort_options" => $sort_options, "request_uri" => $request_uri, "modelName" => $modelName, "modelInstance" => $model, "models" => $models, "columns" => $columns));
     }
     $this->defaultAttrForLayout($modelName, $view);
     return $this->response_with(array("xml", "json", "csv"), $this->collectionToArray($models->results), true);
 }
示例#15
0
 public function update()
 {
     $inputs = Input::all();
     $reglas = array('nombres' => 'required|min:4', 'apellido' => 'required');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $id = Input::get('id');
         $cliente = Cliente::find($id);
         $cliente->nombres = Input::get('nombres');
         $cliente->apellido = Input::get('apellido');
         $cliente->tipo_doc = Input::get('tipo_doc');
         $cliente->documento = Input::get('documento');
         $cliente->email = Input::get('email');
         $cliente->calle = Input::get('calle');
         $cliente->num = Input::get('num');
         $cliente->piso = Input::get('piso');
         $cliente->localidad = Input::get('localidad');
         $cliente->telefono = Input::get('telefono');
         $cliente->celular = Input::get('celular');
         $cliente->save();
         return Redirect::to('lista_clientes')->with('error', 'El Cliente ha sido actualizado con Éxito')->withInput();
     }
 }
 public function postSubmit()
 {
     //Get Form Data
     $data = Input::all();
     // Flashing Input to the session
     Input::flash();
     //Validation rules
     $rules = array('name' => 'required', 'email' => 'required|email', 'subject' => 'required', 'message' => 'required');
     $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
     //Validate data
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         Mail::send('emails.chapters', $data, function ($message) use($data, $emails) {
             $message->from('*****@*****.**');
             foreach ($emails as $email) {
                 $message->to($email)->subject('Yoruba Descendants Contact Request');
             }
         });
         // redirect
         Session::flash('message', 'Message Sent Successful');
         return Redirect::to('chapters');
     } else {
         Session::flash('error', 'Errors on the form,please resubmit');
         return Redirect::to('chapters')->withErrors($validator)->withInput();
     }
 }
示例#17
0
 public function get_index($city = null)
 {
     $inputs = array('pmin' => Input::get('pmin'), 'pmax' => Input::get('pmax'), 'smin' => Input::get('smin'), 'smax' => Input::get('smax'), 'smoking' => Input::get('smoking'), 'pets' => Input::get('pets'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'order' => Input::get('order'));
     if (!is_null($city)) {
         $inputs['city'] = str_replace('-', ' ', $city);
     } else {
         $inputs['city'] = Input::get('city');
     }
     $rules = array('city' => 'exists:photos, city');
     $v = Validator::make($inputs['city'], $rules);
     $query = Room::where('status', '=', 'publish');
     if (!empty($inputs['city'])) {
         $city = $inputs['city'];
         $query->where(function ($query) use($city) {
             $query->where('city', 'LIKE', '%' . $city . '%');
             $query->or_where('description', 'LIKE', '%' . $city . '%');
             $query->or_where('title', 'LIKE', '%' . $city . '%');
         });
     }
     if (!empty($inputs['pmin']) && !empty($inputs['pmax'])) {
         $query->where('price', '>', $inputs['pmin']);
         $query->where('price', '<', $inputs['pmax']);
     }
     if (!empty($inputs['smin']) && !empty($inputs['smax'])) {
         $query->where('surface', '>', $inputs['smin']);
         $query->where('surface', '<', $inputs['smax']);
     }
     if (!empty($inputs['smoking'])) {
         $query->where('smoking', '=', $inputs['smoking']);
     }
     if (!empty($inputs['pets'])) {
         $query->where('pets', '=', $inputs['pets']);
     }
     if (!empty($inputs['toilet'])) {
         $query->where('toilet', '=', $inputs['toilet']);
     }
     if (!empty($inputs['shower'])) {
         $query->where('shower', '=', $inputs['shower']);
     }
     if (!empty($inputs['kitchen'])) {
         $query->where('kitchen', '=', $inputs['kitchen']);
     }
     if (!empty($inputs['order']) && $inputs['order'] == 'price' || $inputs['order'] == 'created_at') {
         $query->order_by($inputs['order'], 'desc');
     } else {
         $query->order_by("created_at", 'desc');
     }
     $total = $query->get();
     $rooms = $query->paginate(Room::$per_page);
     Input::flash();
     if (!$v->fails()) {
         $bgphoto = Photo::where('city', '=', $inputs['city'])->first();
         return View::make('home.search')->with('total', $total)->with('bgphoto', $bgphoto)->with('city', $city)->with('rooms', $rooms);
     } else {
         return View::make('home.search')->with('total', $total)->with('rooms', $rooms);
     }
 }
示例#18
0
 public function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('articles')) {
         return;
     }
     Input::flash();
     $articlecontent = Input::get('ArticleContent');
     $category = Input::get('ArticleCategory');
     $title = Input::get('ArticleTitle');
     $innercat = Input::get('ArticleCategoryInner');
     $saving_id = Input::get('ArticleEditing');
     $articleUrl = Input::get('ArticleTitleUrl');
     $articleStatus = Input::get('StatusSelect');
     $articletype = Input::get('ArticleType');
     $onlySelectTitle = Input::get('OnlyTitleSelect');
     $comments = Input::get('Comments');
     $author = Input::get('Author');
     $addedTags = !isset($_POST['selectorbox']) ? array() : $_POST['selectorbox'];
     //Add rules here
     $rules = array('ArticleTitle' => 'required|max:100', 'ArticleTitleUrl' => 'required', 'ArticleCategory' => 'required', 'ArticleContent' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if (!empty($saving_id) && $validation->fails()) {
         return Redirect::to('/admin/articles/edit?id=' . $saving_id)->with_errors($validation)->with('EditedTags', $addedTags);
     } elseif ($validation->fails()) {
         return Redirect::to('/admin/articles/add')->with_errors($validation)->with('EditedTags', $addedTags);
     }
     if (isset($innercat)) {
         $category = $innercat;
     }
     $temp = !empty($saving_id) ? Article::find($saving_id) : new Article();
     $temp->content = $articlecontent;
     $temp->category_id = $category;
     $temp->title = $title;
     $temp->url = $articleUrl;
     $temp->status = $articleStatus;
     $temp->onlytitle = $onlySelectTitle;
     $temp->articletype = $articletype;
     $temp->author_id = Auth::user()->type == 1 ? $author + 1 : Auth::user()->id;
     $temp->comments = $comments;
     $temp->Tags()->delete();
     echo $temp->save();
     foreach ($addedTags as $tagName) {
         $tagt = Tag::where("tname", "=", $tagName)->first();
         $temp->Tags()->attach($tagt->id);
     }
     Input::flush();
     if (!empty($saving_id)) {
         return Redirect::to('/admin/articles/edit?id=' . $saving_id)->with('EditedTags', $addedTags)->with("successmessage", "Article Edited successfully");
     } else {
         return Redirect::to('/admin/articles/edit?id=' . $temp->id)->with('EditedTags', $addedTags)->with("successmessage", "Article Posted");
     }
 }
 public function save($organization, $orgdata)
 {
     if ($organization->validateAndUpdateFromArray($orgdata)) {
         Session::put('status', 'success');
         Session::put('message', 'Saved!');
         return Redirect::to('organization/' . $organization->id);
     } else {
         Session::put('status', 'error');
         Session::put('message', 'entered data did not validate');
         Input::flash();
         return Redirect::to('organization/' . $organization->id . '/edit')->withInput();
     }
 }
 public function create($recipient = null)
 {
     $user = Confide::user();
     $users = array();
     $userModels = null;
     if ($user->isStaff()) {
         $userModels = DB::table('doctor_patient')->where('doctor_patient.staff_id', '=', $user->id)->join('user', 'doctor_patient.user_id', '=', 'user.id')->select('user.id', 'first_name', 'last_name')->get();
         $users[''] = "-- Select a Patient --";
     } else {
         $userModels = DB::table('doctor_patient')->where('doctor_patient.user_id', '=', $user->id)->join('user', 'doctor_patient.staff_id', '=', 'user.id')->select('user.id', 'first_name', 'last_name')->get();
         $users[''] = "-- Select a Doctor --";
     }
     // Create users array
     foreach ($userModels as $userModel) {
         if ($user->isStaff()) {
             $users[$userModel->id] = $userModel->first_name . " " . $userModel->last_name;
         } else {
             $users[$userModel->id] = "Dr. " . $userModel->first_name . " " . $userModel->last_name;
         }
     }
     if (Request::isMethod('GET')) {
         return View::make('home/conversation/create', compact('user', 'users', 'recipient'));
     } elseif (Request::isMethod('POST')) {
         $messages = array();
         $validator = Validator::make(Input::all(), array('user_id' => 'required', 'subject' => 'required', 'message' => 'required'), array('user_id.required' => 'You must select a recipient.', 'subject.required' => 'You must include a subject.', 'messages.required' => 'You must include a message.'));
         // Get other errors
         if ($validator->fails()) {
             $messageBag = $validator->messages();
             foreach ($messageBag->all(':message<br>') as $message) {
                 $messages[] = $message;
             }
         }
         if (empty($messages)) {
             // Create a new Appointment with the given data
             $conversation = new Conversation();
             $conversation->fill(Input::all());
             $conversation->sender = $user->id;
             $conversation->receiver = Input::get('user_id');
             $conversation->save();
             return Redirect::route('conversation.show.all');
         } else {
             // Flash data to session vars to repopulate form later
             Input::flash();
             // Compile error messages
             $messages = implode($messages);
             return Redirect::route('conversation.create')->with(array('message' => 'Error:<br>' . $messages, 'message_type' => 'error'));
         }
     }
 }
示例#21
0
 public function postContactForm()
 {
     $rules = array('email' => 'email|required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to('/kontakt')->withInput(Input::flash())->withErrors($validator)->with('alert', array('type' => 'error', 'content' => 'Podaj właściwy e-mail'));
     } else {
         Contact::create(Input::all());
         $data['email'] = Input::all();
         Mail::later(5, 'emails.contact', $data, function ($message) {
             $message->to('*****@*****.**')->subject('[hasztag.info] Nowa wiadomość');
         });
         return Redirect::to('/')->with('alert', array('type' => 'success', 'content' => 'Wiadomość wysłana. Odezwiemy się wkrótce!'));
     }
 }
示例#22
0
 public function post_nuevo()
 {
     $inputs = Input::all();
     $reglas = array('serie' => 'required|max:50', 'datatrack' => 'required|max:50');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $avl = new Avl();
         $avl->serie = Input::get('serie');
         $avl->datatrack = Input::get('datatrack');
         $avl->save();
         return Redirect::to('lista_avls')->with('error', 'El Equipo AVL ha sido registrado con Éxito')->withInput();
     }
 }
 public function post_nuevo()
 {
     $inputs = Input::all();
     $reglas = array('serie' => 'required|max:50', 'display' => 'required|max:50', 'modelo' => 'required|max:50');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $radio = new Radio();
         $radio->serie = Input::get('serie');
         $radio->display = Input::get('display');
         $radio->modelo = Input::get('modelo');
         $radio->save();
         return Redirect::to('lista_radios')->with('error', 'El Equipo de Radio ha sido registrado con Éxito')->withInput();
     }
 }
 /**
  * Handle a POST request to remind a user of their password.
  *
  * @return Response
  */
 public function postRemind()
 {
     $rules = array('email' => 'exists:users|email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to("/niepamietam")->withInput(Input::flash())->withErrors($validator)->with('alert', array('type' => 'error', 'content' => 'Błąd! Sprawdź wszystkie pola.'));
     } else {
         switch ($response = Password::remind(Input::only('email'), function ($message) {
             $message->subject('[hasztag.info] Restuj hasło');
         })) {
             case Password::INVALID_USER:
                 return Redirect::back()->with('alert', array('type' => 'error', 'content' => 'Błąd! E-mail nie został wysłany.'));
             case Password::REMINDER_SENT:
                 return Redirect::to('/')->with('alert', array('type' => 'success', 'content' => 'E-mail został wysłany. Sprawdź skrzynkę!'));
         }
     }
 }
 public function update()
 {
     $inputs = Input::all();
     $reglas = array('nombre' => 'required|max:50', 'direccion' => 'required|max:50', 'telefono' => 'required|max:50');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $id_dependencia = Input::get('id');
         $dependencia = Dependencia::find($id_dependencia);
         $dependencia->nombre = Input::get('nombre');
         $dependencia->direccion = Input::get('direccion');
         $dependencia->telefono = Input::get('telefono');
         $dependencia->save();
         return Redirect::to('lista_dependencias')->with('error', 'La dependencia ha sido actualizada con Éxito')->withInput();
     }
 }
示例#26
0
文件: users.php 项目: gischen/PHP-CMS
 function post_add()
 {
     //Flash current values to session
     Input::flash();
     //Same action is used for editing and adding a new category
     $username = Input::get("userName");
     $password = Input::get("userPassword");
     $saving_id = Input::get('editingMode');
     $tempType = Input::get('type');
     $userDisplayName = Input::get('userDisplayName');
     if (!cmsHelper::isCurrentUserAllowedToPerform('users') && $saving_id != Auth::user()->id) {
         return;
     }
     //Add rules here
     $rules = array('userName' => 'required|max:100', 'userPassword' => 'required', 'userDisplayName' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to('/admin/users/add')->with_errors($validation);
     }
     $present = User::where('username', '=', $username)->count();
     if (empty($saving_id) && $present > 0) {
         return Redirect::to('/admin/users/add')->with("errormessage", "User with the same 'username' already exists");
     }
     $present = User::where('displayname', '=', $userDisplayName)->count();
     if (empty($saving_id) && $present > 0) {
         return Redirect::to('/admin/users/add')->with("errormessage", "User with the same 'displayname' already exists");
     }
     $temp = !empty($saving_id) ? User::find($saving_id) : new User();
     $temp->username = $username;
     $temp->password = Hash::make($password);
     $temp->displayname = $userDisplayName;
     if (isset($tempType)) {
         $temp->type = $tempType + 2;
     }
     $temp->save();
     Input::flush();
     return Redirect::to('/admin/users/add')->with("successmessage", !empty($saving_id) ? "User Edited successfuly" : "New User Added successfully");
 }
示例#27
0
 /**
  * Handle add user form
  */
 public function postAdd(Request $request)
 {
     // prepare validation
     $validator = \Validator::make($request->all(), ['first_name' => 'required|max:50', 'last_name' => 'required|max:50', 'display_name' => 'required|max:25|alpha_dash|unique:users', 'email' => 'required|max:255|unique:users', 'password' => 'required|max:255|confirmed', 'password_confirmation' => 'required|max:255']);
     if ($validator->fails()) {
         // flash input and errors to session, then return to form
         $messages = $validator->errors();
         \Input::flash('except', ['password']);
         return \View::make('admin.users.add')->with('messages', $messages);
     } else {
         $input = \Input::all();
         $user = User::create(["first_name" => $input['first_name'], "last_name" => $input['last_name'], "display_name" => $input['display_name'], "email" => $input['email'], "password" => \Hash::make($input['password'])]);
         Role::create(["user_id" => $user->id, "role_name" => $input['role']]);
         \Mail::send('test', [], function (Message $message) {
             $message->from('*****@*****.**', 'Jason Swint');
             $message->to('*****@*****.**', 'Jason Swint');
             $message->subject('New User Created');
         });
     }
 }
 public function post_nuevo()
 {
     $inputs = Input::all();
     $reglas = array('dependencia' => 'required', 'movil' => 'required');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $movdep = new MovilDependencia();
         $movdep->id_dependencia = Input::get('dependencia');
         $movdep->id_movil = Input::get('movil');
         $movdep->save();
         $dependencias = Dependencia::all();
         $moviles = Movil::all();
         $movildependencias = DB::table('dependencias_moviles')->join('dependencias', 'dependencias_moviles.id_dependencia', '=', 'dependencias.id_dependencia')->join('moviles', 'dependencias_moviles.id_movil', '=', 'moviles.id_movil')->select('dependencias.nombre', 'dependencias.id_dependencia', 'dependencias.direccion', 'moviles.dominio', 'moviles.modelo')->orderby('dependencias.id_dependencia', 'asc')->get();
         return View::make('register_movil_dependencia')->with('ok', 'La Asignación ha sido registrada con Éxito')->with('dependencias', $dependencias)->with('moviles', $moviles)->with('movildependencias', $movildependencias);
     }
 }
示例#29
-1
 public function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('categories')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     global $category_title;
     //Same action is used for editing and adding a new category
     $category_title = Input::get("categoryName");
     $category_url = Input::get("categoryNameUrl");
     $parnet_id = Input::get("parentId");
     $category_desc = Input::get("description");
     $saving_id = Input::get('editingMode');
     $counter = 0;
     if ($parnet_id == 0) {
         $counter = Category::where('id', '!=', $saving_id)->where('curl', '=', $category_url)->count();
     } else {
         $counter = Category::where('id', '!=', $saving_id)->where('parent_id', '=', $parnet_id)->where('curl', '=', $category_url)->count();
     }
     //Add rules here
     $rules = array('categoryName' => 'required|max:100', 'categoryNameUrl' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     //Validate rules
     if ($counter > 0 || $validation->fails()) {
         if ($counter == 0) {
             return Redirect::to('/admin/categories/add')->with_errors($validation);
         } else {
             return Redirect::to('/admin/categories/add')->with('errormessage', 'Category with the same name already exists (having the same settings)');
         }
     }
     /* //Check if a category with the same name exists (skip current editing category)
        if (Category::where("cname", '=', $category_title)->where("parent_id", '=', $parnet_id)->where("id", '!=', $saving_id)->count() > 0) {
            echo "Category already present";
            die();
        }*/
     //Check if edit/new post action is performed
     $saveCategory = !empty($saving_id) ? Category::find($saving_id) : new Category();
     $saveCategory->cname = $category_title;
     $saveCategory->curl = $category_url;
     $saveCategory->cdescription = $category_desc;
     $saveCategory->parent_id = $parnet_id != 0 ? $parnet_id : null;
     $saveCategory->save();
     Input::flush();
     //Print appropriate message
     if (!empty($saving_id)) {
         return Redirect::to('/admin/categories/edit?id=' . $saving_id)->with('successmessage', 'Category Edited Successfully');
     } else {
         return Redirect::to('/admin/categories/add')->with('successmessage', 'New Category Added Successfully');
     }
 }
示例#30
-2
 public function post_nuevo()
 {
     $inputs = Input::all();
     $reglas = array('nombre' => 'required|min:4');
     $mensajes = array('required' => 'Campo Obligatorio');
     $validar = Validator::make($inputs, $reglas);
     if ($validar->fails()) {
         Input::flash();
         return Redirect::back()->withInput()->withErrors($validar);
     } else {
         $rubro = new Rubro();
         $rubro->rubro = Input::get('nombre');
         $rubro->save();
         return Redirect::to('lista_rubros')->with('error', 'El Rubrop ha sido registrado con Éxito')->withInput();
     }
 }