示例#1
1
 /**
  * Ce controller à pour but de gérer la logique de recherche d'un film dans la base de données
  * Le controller gère aussi les topics lorsque l'utilisateur fait une recherche via les checkboxes sur
  * la page de d'affichage des résultats.
  * Les fonctions paginate servent à créer le paginator qui est simplement l'affichage des films 20 par 20.
  *
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $search = Input::get('search');
     $topics = Input::except('search', 'page');
     if (empty($topics)) {
         // Pas de topics on renvoie simplement les films correspondants
         $allMovies = Movies::where('title', 'like', "%{$search}%")->paginate(20)->appends(Input::except('page'));
     } else {
         // SI on a des topics dans l'input il est nécessaire de filtrer
         $movies = Topics::whereIn('topic_name', $topics)->with('movies')->get();
         $moviesCollection = Collection::make();
         foreach ($movies as $movy) {
             $moviesCollection->add($movy->movies()->where('title', 'like', "%{$search}%")->get());
         }
         $moviesCollection = $moviesCollection->collapse();
         // Il n'est pas possible de créer la paginator directement, on le crée donc à la main
         $page = Input::get('page', 1);
         $perPage = 20;
         $offset = $page * $perPage - $perPage;
         $allMovies = new LengthAwarePaginator($moviesCollection->slice($offset, $perPage, true), $moviesCollection->count(), $perPage);
         $allMovies->setPath(Paginator::resolveCurrentPath());
         $allMovies->appends(Input::except('page'));
     }
     // A la vue correspondante on lui renvoie une liste des films correspondants à la recherche, le tout paginé
     return view('search', compact('allMovies'));
 }
 public function save($id = null)
 {
     $item = $this->getItem($id);
     $item->fill(Input::except('_token'));
     $item->save();
     return redirect($this->getUrl());
 }
 public function registerCreate()
 {
     $user = DB::table('idenCardNo_HN')->where('idenCardNo', Input::get('idenCardNo'))->first();
     $validator = Validator::make(Input::all(), array('idenCardNo' => 'min:13|idencardno_exist|already_register', 'phoneNo' => 'min:10|unique:users', 'emailAddr' => 'email|unique:users'), array('idenCardNo.min' => 'ท่านกรอกเลขบัตรประจำตัวประชาชนไม่ครบ13หลัก', 'idenCardNo.idencardno_exist' => 'ท่านยังไม่ได้เป็นผู้ป่วยของโรงพยาบาล', 'idenCardNo.already_register' => 'ท่านได้ทำการสมัครสมาชิกไปแล้ว', 'phoneNo.min' => 'ท่านกรอกเบอร์โทรศัพท์ไม่ครบ', 'phoneNo.unique' => 'เบอร์โทรศัพท์นี้มีอยู่ในระบบแล้ว', 'emailAddr.email' => 'รูปแบบอีเมลไม่ถูกต้อง', 'emailAddr.unique' => 'อีเมลนี้มีอยู่ในระบบแล้ว'));
     if ($validator->passes()) {
         $addUser = new User();
         $addUser->type = 'patient';
         $addUser->username = $user->HN;
         $addUser->name = Input::get('name');
         $addUser->surname = Input::get('surname');
         $addUser->birthdate = Input::get('birthdate');
         $addUser->address = Input::get('address');
         $addUser->phoneNo = Input::get('phoneNo');
         $addUser->emailAddr = Input::get('emailAddr');
         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         $charactersLength = strlen($characters);
         $randomString = '';
         for ($i = 0; $i < 8; $i++) {
             $randomString .= $characters[rand(0, $charactersLength - 1)];
         }
         //mail(Input::get('emailAddr'),"ตรวจสอบรหัสผ่านในการเข้าสู่เว็บไซต์ OPDSystem",$randomString ,'');
         $addUser->password = Hash::make($randomString);
         $addUser->save();
         DB::table('idenCardNo_HN')->where('idenCardNo', Input::get('idenCardNo'))->where('HN', $user->HN)->update(array('registered' => 1));
         return Redirect::to('login/register')->with('flash_notice', $randomString);
     } else {
         return Redirect::to('login/register')->withErrors($validator)->withInput(Input::except('password'))->withInput(Input::except('password_confirmation'))->withInput();
     }
 }
 /**
 Method to get information about the logged in user
 @param void
 @return view
 */
 public function userList()
 {
     if (!Auth::check()) {
         return Redirect::to('/');
     }
     $message = '';
     if (Request::isMethod('post')) {
         $data = Input::except('_token');
         $password = Hash::make(Input::get('password'));
         $user = new User();
         $user->name = Input::get('name');
         $user->email = Input::get('email');
         $user->password = $password;
         $username = Input::get('name');
         $userEmail = Input::get('email');
         if ($user->save()) {
             try {
                 Mail::send('emails.welcome', ['userEmail' => $username], function ($m) use($userEmail, $username) {
                     $m->to($userEmail, $username)->subject('Express Rental');
                 });
             } catch (Exception $ex) {
             }
             $message = 'Added Successfully';
             return Redirect::to('/users/list')->with('message', $message);
         } else {
             $message = 'Addition not Successfully';
             return Redirect::to('/users/list')->withErrors('message', $message);
         }
     } else {
         $allUserInfo = DB::table('users')->orderBy('users.id', 'DESC')->paginate(5);
         return view('Home.list')->with(compact('allUserInfo'));
     }
 }
示例#5
0
文件: AdhesionG.php 项目: gAb09/NetP
 public function store()
 {
     // dd(Input::all());
     $adhesion = new Adhesion();
     $adhesion->fill(Input::except('adherent', 'adherent2', '_token', '_method'));
     $adhesion->is_payed = Input::get('is_payed') ? 1 : 0;
     // return dd($adhesion);
     $adhesion->save();
     $type = Input::get('type');
     switch ($type) {
         case 'conso':
             $adhesion->personne()->attach(Input::get('adherent'));
             break;
         case 'couple':
             $adhesion->personne()->attach(Input::get('adherent'));
             $adhesion->personne()->attach(Input::get('adherent2'));
             break;
         case 'pro_personne':
             $adhesion->personne()->attach(Input::get('adherent'));
             break;
         case 'pro_structure':
             $adhesion->structure()->attach(Input::get('adherent'));
             break;
         default:
             dd('problème');
             break;
     }
     // dd($adhesion);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     try {
         $rules = array('username' => 'required', 'email' => 'required|email', 'phone' => 'required|numeric');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('admin/members/')->withErrors($validator)->withInput(Input::except('password'));
         } else {
             // store
             $member = new members();
             $member->username = Input::get('username');
             $member->email = Input::get('email');
             $member->phone = Input::get('phone');
             $member->profilePic = "avatar.png";
             $member->save();
             // redirect
             Session::flash('message', 'Successfully created Member!');
             return Redirect::to('admin/members/');
         }
     } catch (\Illuminate\Database\QueryException $e) {
         Session::flash('error', "SQL Error: " . $e->getMessage() . "\n");
         return Redirect::to('admin/members/');
     }
 }
示例#7
0
 /**
  * get an array of data to use in the response
  * @param Query $query the query to use to retrieve the data
  * @param Paginator $paginator
  * @param array $additionalData an associative array of data to merge with the data array
  */
 protected function getData($query, $additionalData = array())
 {
     //use this hook to alter the parameters
     $paginator = null;
     if (Input::get('page') || $this->paginate) {
         $beforePagination = Event::fire('before.pagination', array(&$query));
         //check if $object is a model or a relation
         $model = $query->getModel();
         $model = method_exists($model, 'getRelated') ? $model->getRelated() : $model;
         $perPage = Input::get('pp') ?: $model->getPerPage();
         $paginator = $query->paginate($perPage);
         //preserve the url query in the paginator
         $paginator->appends(Input::except('page'));
     }
     $results = isset($paginator) ? $paginator->getCollection() : $query->get();
     $data = array();
     $data[$this->resultsKey] = $this->isAjaxRequest() ? $results->toArray() : $results;
     $data['total'] = isset($paginator) ? $paginator->getTotal() : $data->{$this->resultsKey}->count();
     if ($paginator) {
         $data['paginator'] = $paginator;
     }
     if (is_array($additionalData)) {
         $data = array_merge($data, $additionalData);
     }
     return $data;
 }
示例#8
0
 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
     // 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('login')->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
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             return redirect('admin');
         } else {
             // validation not successful, send back to form
             return redirect('login');
         }
     }
 }
示例#9
0
 public function getAllPaging($where = [], $number_pagination = '')
 {
     //check month
     $month = '';
     if (isset($where['month'])) {
         $month = $where['month'];
         unset($where['month']);
     }
     $where_temp = $where;
     foreach ($where_temp as $k => $v) {
         unset($where[$k]);
         $where[$this->table . '.' . $k] = $v;
     }
     $user_in_ex = \App\UserIncomeExpenditure::select($this->table . '.*', 'user.full_name', 'user.first_name', 'user.last_name')->join('user', function ($join) {
         $join->on('user.user_id', '=', $this->table . '.user_id');
     })->where($where);
     if ($month) {
         $user_in_ex = $user_in_ex->whereRaw("DATE_FORMAT(`date`, '%m/%Y') = '" . $month . "'");
     }
     $user_in_ex = $user_in_ex->orderBy($this->table . '.created_at', 'desc');
     if ($number_pagination) {
         $user_in_ex = $user_in_ex->paginate($number_pagination);
         foreach (Input::except('page') as $input => $value) {
             $user_in_ex->appends($input, $value);
         }
     } else {
         $user_in_ex = $user_in_ex->get();
     }
     return $user_in_ex;
 }
示例#10
0
 public function getAllPaging($where = [], $number_pagination = '')
 {
     $where['del_flg'] = 1;
     $channels = null;
     //Split username of channel
     $where_temp = $where;
     foreach ($where_temp as $k => $v) {
         //username
         if (isset($where_temp['daily_channel_username']) && $where_temp['daily_channel_username']) {
             $channels = \App\Channels::where('daily_channel_username', 'LIKE', '%' . $v . '%');
             break;
         }
     }
     if ($channels == null) {
         $channels = \App\Channels::where($where);
     }
     if ($number_pagination) {
         $channels = $channels->paginate($number_pagination);
         foreach (Input::except('page') as $input => $value) {
             $channels->appends($input, $value);
         }
     } else {
         $channels = $channels->get();
     }
     return $channels;
 }
示例#11
0
 public function dologin()
 {
     // validate the info, create rules for the inputs
     $rules = array('username' => 'required', 'password' => 'required');
     // 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('/')->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
         $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
         $remember = Input::has('remember_me') ? true : false;
         // attempt to do the login
         if (Auth::attempt($userdata, $remember)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             return Redirect::to('user/dashboard');
         } else {
             // validation not successful, send back to form
             return Redirect::to('login')->with('message', 'session broken');
         }
     }
 }
示例#12
0
 public function index()
 {
     $model = null;
     $filter = Input::except(["page", "paginado", "cantPage", "relaciones", "orderBy", "filters", "methodFilter"]);
     $filters = Input::get("filters", []);
     if (!empty($filters)) {
         if (!$this->filters($filters)) {
             return $this->respondInternalError();
         }
     }
     $relaciones = Input::get("relaciones", []);
     if (!empty($relaciones)) {
         if (!$this->relations($relaciones)) {
             return $this->respondInternalError();
         }
     }
     $orderBy = Input::get("orderBy", []);
     if (!empty($orderBy)) {
         if (!$this->orderBy($orderBy)) {
             return $this->respondInternalError();
         }
     }
     $methodFilter = Input::get("methodFilter", 'filter');
     $model = call_user_func_array([$this, $methodFilter], [&$filter]);
     if (empty($model)) {
         return $this->respondNotFound();
     }
     $data = ['data' => $model, 'error' => false];
     return $this->respond($data);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $company = Company::findOrFail($id);
     $message = '';
     $users = User::whereRaw('company_id = ? order by first_name', array($company->id))->paginate(15)->appends(Input::except('page'));
     return view('company.show', ['company' => $company, 'users' => $users, 'message' => $message]);
 }
示例#14
0
 public function doRegister()
 {
     $rules = array('password' => 'required|alpha_num|min:3', 'username' => 'required|min:3', 'firstName' => 'required', 'lastName' => 'required');
     // 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('register')->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         $credentials = Input::only('firstName', 'lastName', 'username', 'password');
         $credentials['password'] = Hash::make($credentials['password']);
         try {
             $user = User::create($credentials);
         } catch (Exception $e) {
             return Response::json(['error' => 'User already exists.'], Illuminate\Http\Response::HTTP_CONFLICT);
         }
         $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             return Redirect::to('/');
         } else {
             // validation not successful
             return Redirect::to('/');
         }
     }
 }
示例#15
0
 public function loginData()
 {
     // Getting all post data
     $data = Input::all();
     // Applying validation rules.
     $rules = array('email' => 'required|email', 'password' => 'required|min:6');
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         // If validation falis redirect back to login.
         return Redirect::to('/login')->withInput(Input::except('password'))->withErrors($validator);
     } else {
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         $pasword = Input::get('password');
         $HasPassword = Hash::make($pasword);
         $encriptPassword = bcrypt($pasword);
         echo $HasPassword, "<br>";
         // doing login.
         $validate_admin = DB::table('admintab')->select('email', 'password')->where('email', Input::get('email'))->first();
         echo $FetchPassword = $validate_admin->password;
         if ($FetchPassword == $HasPassword) {
             echo "if statement";
         } else {
             echo "else statement";
         }
         // else {
         //   // if any error send back with message.
         //   Session::flash('error', 'Something went wrong');
         //   return Redirect::to('login');
         // }
     }
 }
示例#16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(CreateMouseRequest $request, $id)
 {
     $input = Input::except('_method', '_token');
     $mouse = Mouse::findOrFail($id);
     $mouse->update($input);
     return redirect('projects/' . $mouse->project_id);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::except(['_token']);
     $ret = $this->repository->createCategory($input);
     if ($ret) {
         return Redirect::to('admin/news/category');
     }
 }
示例#18
0
 public function update($id)
 {
     try {
         $this->roles->update($id, Input::except('role_permissions'), Input::only('role_permissions'));
     } catch (Exception $e) {
         return Redirect::back()->withInput()->withFlashDanger($e->getMessage());
     }
     return Redirect::route('access.roles.index')->withFlashSuccess('The role was successfully updated.');
 }
示例#19
0
 public function results(Request $request)
 {
     $this->validate($request, ['email_home' => 'email', 'email_work' => 'email', 'email_other' => 'email', 'birth_date' => 'date', 'deceased_date' => 'date', 'url_main' => 'url', 'url_work' => 'url', 'url_facebook' => 'url|regex:/facebook\\.com\\/.+/i', 'url_google' => 'url|regex:/plus\\.google\\.com\\/.+/i', 'url_twitter' => 'url|regex:/twitter\\.com\\/.+/i', 'url_instagram' => 'url|regex:/instagram\\.com\\/.+/i', 'url_linkedin' => 'url|regex:/linkedin\\.com\\/.+/i', 'parish_id' => 'integer|min:0', 'gender_id' => 'integer|min:0', 'ethnicity_id' => 'integer|min:0', 'religion_id' => 'integer|min:0', 'contact_type' => 'integer|min:0', 'subcontact_type' => 'integer|min:0', 'occupation_id' => 'integer|min:0', 'emergency_contact_phone' => 'phone', 'emergency_contact_phone_alternate' => 'phone']);
     if (!empty($request)) {
         $persons = \montserrat\Contact::filtered($request)->orderBy('sort_name')->with('attachments')->paginate(100);
         $persons->appends(Input::except('page'));
     }
     return view('search.results', compact('persons'));
 }
示例#20
0
 public function postupdate(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     if (Page::where('id', $id)->update(Input::except(['_method', '_token']))) {
         return Redirect::to('admin/page_operate');
     } else {
         return Redirect::back()->withInput()->withErrors('update success!');
     }
 }
示例#21
0
 public function store(Request $request)
 {
     foreach (Input::except('_token') as $id => $value) {
         $setting = Setting::find($id);
         $setting->value = $value;
         $setting->save();
     }
     return redirect()->route("settings.all")->with('setting-saved', 'Successful saved!');
 }
示例#22
0
 /**
  * Store a newly created resource in storage.
  * ...but in our case are we are updating a whole load of settings this is really the 'update' action.
  */
 public function store()
 {
     $fields = Input::except('_token');
     foreach ($fields as $setting => $value) {
         $data = Setting::where('name', $setting)->first();
         $data->svalue = $value;
         $data->save();
     }
     return Redirect::back()->with('flash_info', 'Application settings have been updated successfully!');
 }
示例#23
0
 public function getIndex()
 {
     $state = Input::get('state');
     $orders = Order::where(function ($q) use($state) {
         if ($state) {
             $q->where('state', '=', $state);
         }
     })->paginate(15)->appends(Input::except('page'));
     return view('admin.orders.index', ['orders' => $orders]);
 }
示例#24
0
 public function postChildComment()
 {
     $validator = Validator::make(Input::all(), ['body' => 'required|min:3', 'user_id' => 'required', 'comment_id' => 'required']);
     if ($validator->passes()) {
         $commentCreated = $this->child->create(Input::except('_token'));
         if ($commentCreated) {
             return redirect()->back()->with(['success' => trans('messages.success.created')]);
         }
     }
     return redirect()->back()->with(['error' => trans('messages.error.updated')]);
 }
示例#25
0
 public function storeSocialData(SocialRequest $request)
 {
     $inputs = Input::except('_token');
     foreach ($inputs as $key => $value) {
         $data = Social::findOrCreate($key);
         $data->key = $key;
         $data->value = $value;
         $data->save();
     }
     return redirect('panel/main-data/social');
 }
示例#26
0
 public function update($id)
 {
     try {
         $this->permissions->update($id, Input::except('permission_roles'), Input::only('permission_roles'));
     } catch (EntityNotValidException $e) {
         return Redirect::back()->with('input', Input::all())->withFlashDanger($e->validationErrors());
     } catch (Exception $e) {
         return Redirect::back()->with('input', Input::all())->withFlashDanger($e->getMessage());
     }
     return Redirect::route('access.roles.permissions.index')->withFlashSuccess("Permission successfully updated.");
 }
示例#27
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $gas = Gas::find($id);
     if ($gas->validate(Input::all(), Gas::$rules)) {
         $gas->update(Input::except('_token'));
         Notification::success('Precio actualizado correctamente');
         return redirect('gas');
     } else {
         $errors = $gas->errors();
         return redirect()->back()->withInput()->withErrors($errors);
     }
 }
 public function doLogin(CreateAdminRequest $request)
 {
     if (Auth::attempt(['username' => $request['username'], 'password' => $request['password']])) {
         $role = Admin::find(Auth::id())->role;
         if ($role !== 'admin') {
             Auth::logout();
         } else {
             return redirect('admin/ajuan');
         }
     }
     return redirect()->back()->withErrors(['error' => 'These credentials do not match our records.'])->withInput(Input::except('password'));
     return redirect('admin/ajuan');
 }
 /**
  * Update the Twitter OAuth keys in storage.
  *
  * @param TwitterConfig $twitterConfig
  * @return Response
  */
 public function update(TwitterConfig $twitterConfig)
 {
     $twitterConfig = $twitterConfig::firstOrFail();
     $input = Input::except('_token');
     $validator = Validator::make($input, TwitterConfigValidator::validationRules());
     if ($validator->fails()) {
         return Redirect::to('admin/twitter_config')->withErrors($validator)->withInput($input);
     }
     $twitterConfig->fill($input);
     $twitterConfig->save();
     Session::flash('success_message_update', 'The Twitter configuration has successfully been updated!');
     return Redirect::to('admin/twitter_config');
 }
示例#30
0
 public function getAllPagingForAdmin($where = [], $number_pagination = '')
 {
     $channel_in_ex = \App\ChannelIncome::select('channel_income.*', 'channel.daily_channel_username', 'channel.daily_channel_name')->join('channel', function ($join) {
         $join->on('channel.daily_channel_id', '=', 'channel_income.daily_channel_id');
     })->where($where)->orderBy('channel_income.date', 'desc');
     if ($number_pagination) {
         $channel_in_ex = $channel_in_ex->paginate($number_pagination);
         foreach (Input::except('page') as $input => $value) {
             $channel_in_ex->appends($input, $value);
         }
     } else {
         $channel_in_ex = $channel_in_ex->get();
     }
     return $channel_in_ex;
 }