only() public static method

Get a subset of the items from the input data.
public static only ( array | mixed $keys ) : array
$keys array | mixed
return array
 /**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $credentials = $request->only('email', 'password', 'password_confirmation');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect($this->redirectPath());
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }
 public function signup()
 {
     $payment_settings = PaymentSetting::first();
     if ($payment_settings->live_mode) {
         User::setStripeKey($payment_settings->live_secret_key);
     } else {
         User::setStripeKey($payment_settings->test_secret_key);
     }
     $token = Input::get('stripeToken');
     $user_data = array('username' => Input::get('username'), 'email' => Input::get('email'), 'password' => Hash::make(Input::get('password')));
     $input = Input::all();
     unset($input['stripeToken']);
     $validation = Validator::make($input, User::$rules);
     if ($validation->fails()) {
         //echo $validation->messages();
         //print_r($validation->errors()); die();
         return Redirect::to('/signup')->with(array('note' => 'Sorry, there was an error creating your account.', 'note_type' => 'error', 'messages'))->withErrors($validation)->withInput(\Request::only('username', 'email'));
     }
     $user = new User($user_data);
     $user->save();
     try {
         $user->subscription('monthly')->create($token, ['email' => $user->email]);
         Auth::loginUsingId($user->id);
         return Redirect::to('/')->with(array('note' => 'Welcome! Your Account has been Successfully Created!', 'note_type' => 'success'));
     } catch (Exception $e) {
         Auth::logout();
         $user->delete();
         return Redirect::to('/signup')->with(array('note' => 'Sorry, there was an error with your card: ' . $e->getMessage(), 'note_type' => 'error'))->withInput(\Request::only('username', 'email'));
     }
 }
 /**
  * Start the creation of a new balance payment
  *   Details get posted into this method
  * @param $userId
  * @throws \BB\Exceptions\AuthenticationException
  * @throws \BB\Exceptions\FormValidationException
  * @throws \BB\Exceptions\NotImplementedException
  */
 public function store($userId)
 {
     $user = User::findWithPermission($userId);
     $this->bbCredit->setUserId($user->id);
     $requestData = \Request::only(['reason', 'amount', 'return_path', 'ref']);
     $amount = $requestData['amount'] * 1 / 100;
     $reason = $requestData['reason'];
     $returnPath = $requestData['return_path'];
     $ref = $requestData['ref'];
     //Can the users balance go below 0
     $minimumBalance = $this->bbCredit->acceptableNegativeBalance($reason);
     //What is the users balance
     $userBalance = $this->bbCredit->getBalance();
     //With this payment will the users balance go to low?
     if ($userBalance - $amount < $minimumBalance) {
         if (\Request::wantsJson()) {
             return \Response::json(['error' => 'You don\'t have the money for this'], 400);
         }
         \Notification::error("You don't have the money for this");
         return \Redirect::to($returnPath);
     }
     //Everything looks gooc, create the payment
     $this->paymentRepository->recordPayment($reason, $userId, 'balance', '', $amount, 'paid', 0, $ref);
     //Update the users cached balance
     $this->bbCredit->recalculate();
     if (\Request::wantsJson()) {
         return \Response::json(['message' => 'Payment made']);
     }
     \Notification::success("Payment made");
     return \Redirect::to($returnPath);
 }
 public function login()
 {
     $data = Request::only('email', 'password');
     $data['password'] = md5($data['password']);
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:6');
     $validator = Validator::make($data, $rules);
     $result = array('errors' => '', 'result' => '');
     if ($validator->fails()) {
         $messages = $validator->messages();
         foreach ($messages->all() as $message) {
             $result['errors'] .= "<li>{$message}</li>";
         }
         return json_encode($result);
     }
     $user = new User();
     $response = $user->login($data);
     if ($response['status'] === true) {
         $sessionData = array();
         $sessionData['id'] = $response['id'];
         $sessionData['email'] = $response['email'];
         $result['result'] = 'success';
         Session::put('user_data', $sessionData);
     } else {
         $result['errors'] = 'Username or password incorrect. Please try again';
     }
     return json_encode($result);
 }
Example #5
0
 public function compose(View $view)
 {
     $documentForm = \Request::only('responsable_id');
     $route = Route::currentRouteName();
     $users = User::orderBy('name', 'ASC')->lists('name', 'id')->toArray();
     $view->with(compact('documentForm', 'users', 'route'));
 }
 /**
  * Start the creation of a new gocardless payment
  *   Details get posted into this method and the redirected to gocardless
  * @param $userId
  * @throws \BB\Exceptions\AuthenticationException
  * @throws \BB\Exceptions\FormValidationException
  * @throws \BB\Exceptions\NotImplementedException
  */
 public function store($userId)
 {
     User::findWithPermission($userId);
     $requestData = \Request::only(['reason', 'amount', 'return_path', 'stripeToken', 'ref']);
     $stripeToken = $requestData['stripeToken'];
     $amount = $requestData['amount'];
     $reason = $requestData['reason'];
     $returnPath = $requestData['return_path'];
     $ref = $requestData['ref'];
     try {
         $charge = Stripe_Charge::create(array("amount" => $amount, "currency" => "gbp", "card" => $stripeToken, "description" => $reason));
     } catch (\Exception $e) {
         \Log::error($e);
         if (\Request::wantsJson()) {
             return \Response::json(['error' => 'There was an error confirming your payment'], 400);
         }
         \Notification::error("There was an error confirming your payment");
         return \Redirect::to($returnPath);
     }
     //Replace the amount with the one from the charge, this prevents issues with variable tempering
     $amount = $charge->amount / 100;
     //Stripe don't provide us with the fee so this should be OK
     $fee = $amount * 0.024 + 0.2;
     $this->paymentRepository->recordPayment($reason, $userId, 'stripe', $charge->id, $amount, 'paid', $fee, $ref);
     if (\Request::wantsJson()) {
         return \Response::json(['message' => 'Payment made']);
     }
     \Notification::success("Payment made");
     return \Redirect::to($returnPath);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $role = Role::findOrFail($id);
     $formData = \Request::only(['description', 'title', 'email_public', 'email_private', 'slack_channel']);
     $this->roleValidator->validate($formData);
     $role->update($formData);
     return \Redirect::back();
 }
 public function update($proposalId)
 {
     $this->proposalValidator->validate(\Request::all(), $proposalId);
     $data = \Request::only('title', 'description', 'start_date', 'end_date');
     $this->proposalRepository->update($proposalId, $data);
     \Notification::success("Proposal updated");
     return \Redirect::route('proposals.index');
 }
Example #9
0
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function block($id)
 {
     $shop = Shops::find($id);
     $input = \Request::only('blocked')['blocked'];
     $shop->blocked = $input;
     $shop->update();
     return redirect()->route('admin.shops.index');
 }
 public function store()
 {
     $this->feedbackValidator->validate(\Request::only('comments'));
     $memberName = \Auth::user()->name;
     \Mail::queue('emails.feedback', ['memberName' => $memberName, 'comments' => \Request::get('comments')], function ($message) {
         $message->to('arthur@arthurguy.co.uk', 'Arthur Guy')->subject('BBMS Feedback');
     });
     return \Response::json(['success' => 1]);
 }
 public function store()
 {
     $data = new Kadis();
     dd(Request::only('title', 'zaki'));
     if ($data->fill([])->save()) {
         return redirect()->route('kadis.index');
     }
     return route('kadis.index');
 }
 /**
  * Handle the reauthentication request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Orchestra\Foundation\Validation\Account  $validator
  *
  * @return mixed
  */
 public function reauth(Request $request, AccountValidator $validator)
 {
     $validation = $validator->on('reauthenticate')->with($request->only(['password']));
     if ($validation->fails()) {
         return $this->userReauthenticateHasFailedValidation($validation->getMessageBag());
     } elseif (!(new ReauthLimiter($request))->attempt($request->input('password'))) {
         return $this->userHasFailedReauthentication();
     }
     return $this->userHasReauthenticated();
 }
 public function in()
 {
     $credentials = \Request::only('email', 'password');
     if ($token = \JWTAuth::attempt($credentials)) {
         $response = response()->json(['token' => $token]);
     } else {
         $response = response()->json(['errors' => ['The email/password is invalid.']], 400);
     }
     return $response;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($roleId)
 {
     $formData = \Request::only(['user_id']);
     $this->roleUserValidator->validate($formData);
     $role = Role::findOrFail($roleId);
     //If the user isnt already a member add them
     if (!$role->users()->get()->contains($formData['user_id'])) {
         $role->users()->attach($formData['user_id']);
     }
     return \Redirect::back();
 }
 public function postLogin()
 {
     $credentials = Request::only('email', 'password');
     $validator = Validator::make($credentials, ['email' => 'required|email', 'password' => 'required']);
     if ($validator->valid()) {
         if (Auth::attempt($credentials)) {
             return Redirect::intended('/');
         }
     }
     return Redirect::to('auth/login')->withInput(Request::only('email'))->withErrors(['email' => 'Invalid credentials']);
 }
 function patch_store($id)
 {
     $store = Store::findByPublicId($id);
     $input = Request::only('title', 'description');
     $validation = Validator::make($input, array('title' => 'required', 'description' => ''));
     if ($validation->fails()) {
         return response()->json(array('status' => 'error', 'messages' => $validation->messages()));
     }
     $store->update(array('title' => $input['title'], 'description' => $input['description']));
     return response()->json(array('status' => 'success', 'data' => $store->toArray()));
 }
 public function authenticate(Request $request)
 {
     try {
         $credentials = \Request::only('email', 'password');
         if (!($token = \JWTAuth::attempt($credentials))) {
             return \Response::json(['error' => 'invalid_credentials'], 401);
         }
         return \Response::json(compact('token'));
     } catch (JWTException $e) {
         return \Response::json(['error' => 'could_not_create_token'], 500);
     }
 }
 public function handle()
 {
     $data = \Request::only(['device', 'tag', 'service']);
     try {
         $keyFob = $this->keyFobAccess->lookupKeyFob($data['tag']);
     } catch (\Exception $e) {
         \Log::debug(json_encode($data));
         return \Response::make('Not found', 404);
     }
     $user = $keyFob->user()->first();
     $this->paymentRepository->recordPayment($data['service'], $user->id, 'balance', null, 0.05, 'paid', 0, $data['device']);
     event(new MemberActivity($keyFob, $data['service']));
     return \Response::make('OK', 201);
 }
 /**
  * Main entry point for all gocardless payments - not subscriptions
  * @param $userId
  * @return mixed
  * @throws \BB\Exceptions\AuthenticationException
  */
 public function create($userId)
 {
     $user = User::findWithPermission($userId);
     $requestData = \Request::only(['reason', 'amount', 'return_path']);
     $reason = $requestData['reason'];
     $amount = $requestData['amount'] * 1 / 100;
     $returnPath = $requestData['return_path'];
     $ref = $this->getReference($reason);
     if ($user->payment_method == 'gocardless-variable') {
         return $this->handleBill($amount, $reason, $user, $ref, $returnPath);
     } elseif ($user->payment_method == 'gocardless') {
         return $this->ddMigratePrompt($returnPath);
     } else {
         return $this->handleManualBill($amount, $reason, $user, $ref, $returnPath);
     }
 }
 public function authenticate(Request $request)
 {
     // grab credentials from the request
     $credentials = $request->only('email', 'password');
     try {
         // attempt to verify the credentials and create a token for the user
         if (!($token = JWTAuth::attempt($credentials))) {
             return response()->json(['error' => 'invalid_credentials'], 401);
         }
     } catch (JWTException $e) {
         // something went wrong whilst attempting to encode the token
         return response()->json(['error' => 'could_not_create_token'], 500);
     }
     // all good so return the token
     return response()->json(compact('token'));
 }
Example #21
0
 /**
  * The actual Save action, which does all of hte pre-processing
  * required before we are able to perform the save() function.
  * 
  * @return
  */
 private function doSave()
 {
     foreach (\Request::only(array_keys($this->fields)) as $key => $value) {
         if ($this->hasSetMutator($key)) {
             $this->setAttribute($key, $value);
             continue;
         }
         // Could swap this out for model -> getAttribute, then check if we have an attribute or a relation... getRelationValue() is helpful
         if (method_exists($this->model, $key) && is_a(call_user_func_array([$this->model, $key], []), 'Illuminate\\Database\\Eloquent\\Relations\\Relation')) {
             $this->saveRelation('doSave', $key, $value);
             continue;
         }
         $this->model->setAttribute($key, $value);
     }
     $this->model->save();
     event(new ModelSave($this));
 }
Example #22
0
 /**
  * Reset the given user's password.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postDefine(Request $request)
 {
     $v = \Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required|different:old_password|min:6', 'old_password' => 'required'], ['password.different' => 'Le champ nouveau mot de passe doit être différent du mot de passe actuel']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors());
     }
     $email = $request->input('email');
     $password = $request->input('password');
     $old_password = $request->input('old_password');
     if (\Auth::attempt(['email' => $email, 'password' => $old_password])) {
         $user = \Auth::user();
         $user->password = bcrypt($password);
         $user->save();
         \Auth::login($user);
         return redirect('user')->with(['status' => 'success', 'message' => 'Votre mot de passe a bien été changé']);
     }
     return redirect()->back()->with(['status' => 'danger', 'message' => 'Les identifiants email / mot de passe ne correspondent pas'])->withInput($request->only('email'));
 }
 public function store()
 {
     $rules = ['name' => 'required|min:6|unique:users', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6'];
     $input = \Request::only('name', 'email', 'password', 'password_confirmation');
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return \Redirect::back()->withInput()->withErrors($validator);
     }
     $confirmation_code = str_random(30);
     $email = \Request::get('email');
     $user = \App\User::create(['name' => \Request::get('name'), 'email' => \Request::get('email'), 'password' => \Hash::make(\Request::get('password')), 'confirmation_code' => $confirmation_code]);
     if ($user) {
         \Mail::send('auth.emails.verify', ['confirmation_code' => $confirmation_code, 'email' => $email], function ($message) {
             $message->to(\Request::get('email'), \Request::get('name'))->subject('confirmation');
         });
     }
     \Session::flash('flash_message', 'Thanks for registration cjeck email');
     return \Redirect::home();
 }
Example #24
0
 /**
  * Datasource de dados para a listagem
  * @param  array $fields Campos para serem buscados
  * @param  int $limit  Valor de limite
  * @param  int|string $order  Campo de ordenacao
  * @param  string $card   Cardinalidade do campo de ordenacao
  * @return object
  */
 protected function _datasource($fields, $order, $card, $limit, $offset = false, $fields_filter = null)
 {
     $whereGlobal = array();
     foreach ($fields_filter as $key => $value) {
         if (isset($value['filter']['global']) && $value['filter']['global']) {
             $whereGlobal[] = $value['filter']['global'];
             // $whereGlobal[] = "SEM_ACENTO({$value['name']}::varchar) ilike '%{$strf}%'";
         }
     }
     // mdd($whereGlobal);
     // DB::listen(function($query){
     //     echo $query->sql."\n\n\n";
     // });
     // ->whereHas('cod_paiss', function($query){
     //     $query->whereRaw("ind_status = 'A'");
     // })
     $rows = $this->model;
     // foreach ($wheres as $where) {
     $rows = $rows->whereRaw('(' . implode(' or ', $whereGlobal) . ')');
     // }
     $rows = $rows->orderBy($order, $card)->paginate($limit, $fields)->appends(\Request::only(['order', 'card', 'perpage', 'filter']));
     // mdd($rows);
     return $rows;
 }
 public function store()
 {
     $data = \Request::only('device', 'service', 'message', 'tag', 'time', 'payload', 'signature', 'nonce');
     //device = the device id from the devices table - unique to each piece of hardware
     //service = what the request is for, entry, usage, consumable
     //message = system message, heartbeat, boot
     //tag = the keyfob id
     //time = the time of the action
     //payload = any extra data relavent to the request
     //signature = an encoded value generated using a secret key - oauth style
     //nonce = a unique value suitable to stop replay attacks
     $this->ACSValidator->validate($data);
     //System messages
     if (in_array($data['message'], ['boot', 'heartbeat'])) {
         return $this->handleSystemCheckIn($data['message'], $data['device'], $data['service']);
     }
     switch ($data['service']) {
         case 'entry':
             return $this->handleDoor($data);
         case 'usage':
             return $this->handleDevice($data);
         case 'consumable':
             break;
         case 'shop':
             break;
         case 'status':
             return $this->returnMemberStatus($data);
             break;
         case 'device-scanner':
             $this->logDetectedDevices($data);
             break;
         default:
             \Log::debug(json_encode($data));
     }
     $responseArray = ['time' => time(), 'command' => null, 'valid' => true, 'available' => true, 'member' => null];
 }
Example #26
0
    // dd($data);
    // De los live sacar los puntos para las gráficas
    foreach ($data['live'] as $device) {
        foreach ($device->sensors as $sensor) {
            // $points['arduino1']['2015-07-19 14:30']['humedad1'] = 35
            //$points[$device->name]['by_date'][$sensor->created_at->toDateTimeString()][$sensor->type] = $sensor->value;
            // $points['arduino1']['humedad1'][] = ['2015-07-19 14:30', 35]
            $points[$device->name][$sensor->type][] = [$sensor->created_at->timestamp, $sensor->value];
        }
    }
    // pasamos los datos a la vista para allí pasarlo al JS
    $data['toJavascript']['points'] = $points;
    return view('dashboard')->with($data);
});
Route::get('store/{name}', function ($name) {
    $input = Request::only('temperatura', 'luz', 'humedad1', 'humedad2', 'humedad3', 'humedad4');
    if (!($device = Device::find($name))) {
        $device = App\Device::create(['name' => $name]);
        $device->save();
        $device->name = $name;
        $device = Device::find($name);
    }
    foreach ($input as $type => $value) {
        if ($value != null) {
            $sensor = new App\Sensor(['type' => $type, 'value' => $value]);
            $device->sensors()->save($sensor);
        }
    }
    return Device::with('sensors')->find($name);
});
Route::get('devices/{name}', function ($name) {
				<td valign="bottom"><p>{{ $post->slug }}</p></td>
				<td><p>{{ $post->active }}</p></td>
				<td>
					<p>
						<a href="{{ URL::to('admin/posts/edit') . '/' . $post->id }}" class="btn btn-xs btn-info"><span class="fa fa-edit"></span> Edit</a>
						<a href="{{ URL::to('admin/posts/delete') . '/' . $post->id }}" class="btn btn-xs btn-danger delete"><span class="fa fa-trash"></span> Delete</a>
					</p>
				</td>
			</tr>
			@endforeach
	</table>

	<div class="clear"></div>

	<div class="pagination-outter"><?php 
echo $posts->appends(Request::only('s'))->render();
?>
</div>
	<script src="{{ '/application/assets/admin/js/sweetalert.min.js' }}"></script>
	<script>

		$ = jQuery;
		$(document).ready(function(){
			var delete_link = '';

			$('.delete').click(function(e){
				e.preventDefault();
				delete_link = $(this).attr('href');
				swal({   title: "Are you sure?",   text: "Do you want to permanantly delete this post?",   type: "warning",   showCancelButton: true,   confirmButtonColor: "#DD6B55",   confirmButtonText: "Yes, delete it!",   closeOnConfirm: false }, function(){    window.location = delete_link });
			    return false;
			});
 public function addPhoto($equipmentId)
 {
     $equipment = $this->equipmentRepository->findBySlug($equipmentId);
     $data = \Request::only(['photo']);
     $this->equipmentPhotoValidator->validate($data);
     if (\Input::file('photo')) {
         try {
             $filePath = \Input::file('photo')->getRealPath();
             $ext = \Input::file('photo')->guessClientExtension();
             $mimeType = \Input::file('photo')->getMimeType();
             $fileData = \Image::make($filePath)->fit(1000)->encode($ext);
             $newFilename = str_random() . '.' . $ext;
             Storage::put($equipment->getPhotoBasePath() . $newFilename, (string) $fileData, 'public');
             $equipment->addPhoto($newFilename);
         } catch (\Exception $e) {
             \Log::error($e);
             throw new ImageFailedException($e->getMessage());
         }
     }
     \Notification::success("Image added");
     return \Redirect::route('equipment.edit', $equipmentId);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  * @throws \BB\Exceptions\AuthenticationException
  */
 public function update($id)
 {
     /**
     if (\Request::ajax()) {
         $data = \Request::only(['category', 'description', 'amount', 'expense_date']);
     
         $expense = \BB\Entities\Expense::findOrFail($id);
         $expense = $expense->update($data);
     
         return $expense;
     }
     */
     if (!\Auth::user()->hasRole('admin')) {
         throw new \BB\Exceptions\AuthenticationException();
     }
     $data = \Request::only('approve', 'decline');
     if (!empty($data['approve'])) {
         $this->expenseRepository->approveExpense($id, \Auth::user()->id);
     }
     if (!empty($data['decline'])) {
         $this->expenseRepository->declineExpense($id, \Auth::user()->id);
     }
     return \Redirect::route('expenses.index');
 }
 protected function getCredentials(Request $request)
 {
     return $request->only($this->loginUsername(), 'password');
 }