本文整理汇总了PHP中request::only方法的典型用法代码示例。如果您正苦于以下问题:PHP request::only方法的具体用法?PHP request::only怎么用?PHP request::only使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request
的用法示例。
在下文中一共展示了request::only方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateMerchantOtp
public function validateMerchantOtp(request $request)
{
$apiKey = $request->only('api_key');
$validator = Validator::make($apiKey, ['api_key' => 'required']);
if ($validator->fails()) {
$response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
return $response;
}
$role = Role::find(2);
$key = Config::get('custom.JWTkey');
$decoded = JWT::decode($apiKey['api_key'], $key, array('HS256'));
if ($decoded->type != 'merchant') {
return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
}
$user = User::find($decoded->sub);
// check the current user
if (empty($user) || !$user->hasRole(['merchant']) || !$user->status) {
return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
}
$user_id = $user->id;
$input = $request->only('otp');
$matchThese = ['user_id' => $user_id, 'code' => $input['otp']];
$sms = UserSmsCode::where($matchThese)->first();
if ($sms == '' || empty($sms)) {
return response()->json(['response_code' => 'RES_IOG', 'messages' => 'Invalid OTP Given'], 422);
}
$sms->status = true;
$sms->save();
$user->is_mobile_verified = true;
$user->save();
return response()->json(['response_code' => 'RES_MV', 'messages' => 'Mobile Verified']);
}
示例2: redeemCoupon
public function redeemCoupon(request $request)
{
$rules = array('client_id' => 'required', 'client_secret' => 'required', 'code' => 'required', 'mobile' => 'required|size:10', 'email' => 'required|email|max:255');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'message' => $validator->errors()->all()], 400);
}
$auth = $request->only('client_id', 'client_secret');
$server = ['client_id' => Config::get('custom.client_id'), 'client_secret' => Config::get('custom.client_secret')];
if ($server['client_id'] != $auth['client_id'] || $server['client_secret'] != $auth['client_secret']) {
return response()->json(['response_code' => 'ERR_IAC', 'messages' => 'Invalid Api credentials'], 403);
}
$code = $request->only('code');
$matchThese = ['code' => $code['code'], 'is_active' => true];
$store = Store::where($matchThese)->first();
if ($store == '' || empty($store)) {
return response()->json(['response_code' => 'ERR_CCNV', 'message' => 'Coupon Code Not valid'], 409);
}
if ($this->userExists($request->only('email'))) {
return response()->json(['response_code' => 'ERR_UAUC', 'message' => 'User Already Used Coupon'], 409);
}
$input = $request->only('name', 'email', 'mobile');
$input['store_id'] = $store->id;
$customer = Customer::create($input);
$data['timer'] = $store->timer;
$data['offer_image'] = URL::to('/assets/img/stores/') . $store->offer_image;
return response()->json(['response_code' => 'RES_CRS', 'message' => 'Coupon Redeemed successfully', 'data' => $data]);
}
示例3: addOffer
public function addOffer(request $request)
{
$validator = Validator::make($request->all(), ['store_id' => 'required', 'title' => 'required|max:255', 'startDate' => 'required|date', 'endDate' => 'required|date', 'fineprint' => 'required|min:5']);
$input = $request->only('store_id');
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/addoffer')->withErrors($validator);
}
$offer = Offers::create($request->only('store_id', 'title', 'fineprint', 'startDate', 'endDate'));
return redirect('admin/store/' . $input['store_id'] . '/offers/all');
}
示例4: postMerchantLogin
public function postMerchantLogin(request $request)
{
$credentials = $request->only('email', 'password');
$rules = array('email' => 'required', 'password' => 'required');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'messages' => $validator->errors()->all()], 400);
}
if (Auth::once(array('email' => $credentials['email'], 'password' => $credentials['password']))) {
$user = Auth::user();
if ($user->hasRole('merchant')) {
if ($user->status && $user->is_mobile_verified) {
return $this->login($user, 'merchant');
} else {
return response()->json(['response_code' => 'RES_IAU', 'message' => 'In Active User'], 403);
}
} else {
return response()->json(['response_code' => 'ERR_WUC', 'messages' => 'Wrong User Credentials'], 404);
}
}
return response()->json(['response_code' => 'ERR_WUC', 'messages' => 'Wrong User Credentials'], 404);
}
示例5: editProfile
public function editProfile(request $request)
{
$rules = array('email' => 'unique:users');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
return response()->json(['response_code' => 'ERR_EAE', 'message' => 'Email Already Exists'], 409);
}
$user_id = Auth::user()->id;
$user = User::find($user_id);
foreach ($request->only('name', 'email') as $key => $value) {
$user->{$key} = $value;
}
if ($request->hasFile('profileImg')) {
$image = $request->file('profileImg');
$imageName = strtotime(Carbon::now()) . md5($user_id) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/users/' . $imageName);
Image::make($image->getRealPath())->resize(280, 240)->save($path);
$user->profileImg = $imageName;
}
$user->save();
return response()->json(['response_code' => 'RES_UU', 'messages' => 'User Upadated', 'data' => $user]);
}
示例6: test
public function test(request $request)
{
$token = $request->only('token');
$response = Curl::to('https://graph.facebook.com/v2.5/me?access_token=' . $token['token'] . '&fields=id,name,email')->asJson()->get();
return $response->email;
}
示例7: changePassword
public function changePassword(request $request)
{
$input = $request->only('new', 'token');
$validator = Validator::make($input, ['token' => 'required', 'new' => 'required']);
if ($validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'message' => $validator->errors()->all()], 400);
}
$check = PasswordOtpReset::where('token', $input['token'])->first();
if (empty($check) || $check == '' || !$check->is_verified) {
return response()->json(['response_code' => 'RES_ITK', 'messages' => 'Invalid Token Key'], 422);
}
$user = User::where('id', $check->user_id)->first();
$user->password = bcrypt($input['new']);
$user->save();
$check->delete();
return response()->json(['response_code' => 'RES_PC', 'message' => 'Password Changed']);
}
示例8: addOffer
public function addOffer(request $request)
{
$rules = array('title' => 'required', 'fineprint' => 'required', 'startDate' => 'required', 'endDate' => 'required');
$Validator = $this->customValidator($request->all(), $rules, array());
if ($Validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'messages' => $Validator->errors()->all()], 400);
}
$is_parent = false;
$offerArr = $request->only('title', 'fineprint');
$offerArr['startDate'] = date('Y-m-d H:i:s', strtotime($request->input('startDate')));
$offerArr['endDate'] = date('Y-m-d H:i:s', strtotime($request->input('endDate')));
if ($request->has('store_token')) {
if ($request->input('store_token') == 'all' && Auth::user()->Stores->is_parent) {
$store_id = Auth::user()->Stores->id;
$is_parent = true;
} else {
if ($request->input('store_token') == 'all') {
return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
} else {
$storeId = Crypt::decrypt($request->input('store_token'));
if (!$this->checkUserHasStorePermission($storeId)) {
return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
}
$store_id = $storeId;
}
}
} else {
$store_id = Auth::user()->Stores->id;
}
$offerArr['store_id'] = $store_id;
$offer = Offers::create($offerArr);
if ($is_parent) {
//creating offer for all sub merchants if user selects and if he is super merchant
$offer->is_parent = true;
$offer->save();
$matchThese = ['is_child' => true, 'parent_id' => $store_id];
$stores = MerchantStore::where($matchThese)->get();
$offerInp = $request->only('title', 'fineprint', 'startDate', 'endDate');
$offerInp['is_child'] = true;
$offerInp['parent_id'] = $offer->id;
foreach ($stores as $store) {
$offerInp['store_id'] = $store->id;
Offers::create($offerInp);
}
}
return response()->json(['response_code' => 'RES_SOC', 'messages' => 'Store Offer Created', 'data' => $offer], 201);
}
示例9: searchStoreCustomer
public function searchStoreCustomer(request $request, $id)
{
$query = $request->only('q');
$customers = Customer::where('store_id', $id)->where('name', 'LIKE', '%' . $query['q'] . '%')->orWhere('mobile', 'LIKE', '%' . $query['q'] . '%')->orWhere('email', 'LIKE', '%' . $query['q'] . '%')->paginate(15);
$output = array('customers' => $customers, 'store_id' => $id);
return view('admin.storeCustomers', $output);
}
示例10: changePassword
public function changePassword(request $request)
{
$rules = array('new' => 'required|min:6', 'old' => 'required');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'message' => $validator->errors()->all()], 400);
}
$input = $request->only('old', 'new');
if (!Hash::check($input['old'], Auth::user()->password)) {
return response()->json(['response_code' => 'ERR_IP', 'message' => 'Invalid password'], 409);
}
$id = Auth::user()->id;
$user = User::find($id);
$user->password = bcrypt($input['new']);
$user->save();
return response()->json(['response_code' => 'RES_PC', 'message' => 'Password Changed']);
}
示例11: customerLogin
public function customerLogin(request $request)
{
$userInput = $request->only('username', 'password');
$field = filter_var($userInput['username'], FILTER_VALIDATE_EMAIL) ? 'email' : 'mobile';
$rules = array($field => 'required', 'password' => 'required');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
$response = array('status' => fail, 'messages' => $validator->errors()->all());
return $response;
}
if (Auth::attempt(array($field => $userInput['username'], 'password' => $userInput['password']))) {
return $this->login(Auth::user());
}
$response = array('status' => fail, 'messages' => 'Wrong User Credentials');
return $response;
}
示例12: makeVote
public function makeVote(request $request)
{
$rules = array('offer_id' => 'required');
$Validator = $this->customValidator($request->all(), $rules, array());
if ($Validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'messages' => $Validator->errors()->all()], 400);
}
$input = $request->only('offer_id');
$offer_id = $input['offer_id'];
$user_id = Auth::user()->id;
if ($this->ifOfferHasVote($offer_id, $user_id)) {
$offer = Offers::find($offer_id);
/*$offer->Votes()->updateExistingPivot($user_id,['status'=>$input['status']]);*/
$offer->Votes()->detach([$user_id]);
return response()->json(['response_code' => 'ERR_OVR', 'messages' => 'Offer Vote Removed'], 204);
}
$offer = Offers::find($offer_id);
$offer->Votes()->attach([$user_id]);
return response()->json(['response_code' => 'RES_OMF', 'messages' => 'Offer Voted'], 204);
}
示例13: changePassword
public function changePassword(request $request)
{
$rules = array('new' => 'required|min:6', 'old' => 'required');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
return redirect('merchant/profile/edit')->withErrors($validator);
}
$input = $request->only('old', 'new');
if (!Hash::check($input['old'], Auth::user()->password)) {
return redirect('merchant/profile/edit')->with('status1', 'Invalid Password');
}
$id = Auth::user()->id;
$user = User::find($id);
$user->password = bcrypt($input['new']);
$user->save();
return redirect('merchant/profile/edit')->with('status1', 'Password Changed!');
}