本文整理汇总了PHP中request::all方法的典型用法代码示例。如果您正苦于以下问题:PHP request::all方法的具体用法?PHP request::all怎么用?PHP request::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request
的用法示例。
在下文中一共展示了request::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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]);
}
示例2: login
public function login(request $request)
{
$input = $request->all();
if (Auth::attempt(['email' => $input['email'], 'password' => $input['password']])) {
return Redirect::route('home');
} else {
return Redirect::route('home')->with('loginFail', ['fail']);
}
}
示例3: login
public function login()
{
$rules = array('email' => 'required|email', 'password' => 'required|min:6');
$messages = ['email.required' => 'Yêu cầu nhập email.', 'email.email' => 'Email sai định dạng. Yêu cầu nhập lại.', 'password.required' => 'Yêu cầu nhập mật khẩu.', 'password.min' => 'Mật khẩu cần lớn hơn hoặc bằng 6.'];
$validator = Validator::make(request::all(), $rules, $messages);
if ($validator->fails()) {
return view::make('admin/login')->withInput(request::except('password'))->withErrors($validator);
}
$userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
if (Auth::attempt($userdata)) {
return view::make('admin/index');
} else {
return view::make('admin/login');
}
}
示例4: postCreate
public function postCreate(request $request)
{
$validator = Validator::make($request->all(), User::$rules);
if ($validator->passes()) {
$user = new User();
//实例化User对象
$user->name = $request['name'];
$user->email = $request['email'];
$user->password = Hash::make($request['password']);
$user->save();
return Redirect::to('auth/login')->with('message', '欢迎注册,好好玩耍!');
} else {
return Redirect::to('auth/register')->with('message', '请您正确填写下列数据')->withErrors($validator)->withInput();
}
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update($id)
{
$this->site = Site::whereId($id)->first();
Helper::allow('site-edit', $this->site);
$this->site = new Site($this->request->all());
$this->site->id = $id;
$this->site->city_id = City::getCityFromAutoComplete($this->site->city_id);
$this->_requestFormCheck();
$this->site->barangay_id = $this->_checkNewBarangay($this->request, $this->site);
$this->_putCategories();
$this->site->can_comment = isset($this->site->can_comment);
$this->site->auto_comments = isset($this->site->auto_comments);
unset($this->site->categories);
DB::table('sites')->where('id', $id)->update($this->site->toArray());
//$this->_fileUploaded();
return redirect(route('sites.index'))->with(['success' => 'Your business ' . $this->site->name . ' has been updated!']);
}
示例6: addArticle
public function addArticle(Request $request)
{
$rules = array('title' => 'required', 'summary' => 'required', 'articleContent' => 'required', 'category' => 'required|not_in:0', 'author' => 'required');
$messages = ['title.required' => 'Bài viết cần có tiêu đề.', 'summary.required' => 'Tóm lược không được trống.', 'articleContent.required' => 'Nội dung không được trống.', 'category.required' => 'Chọn chuyên mục.', 'category.not_in' => 'Chọn chuyên mục.', 'author.required' => 'Nhập tên tác giả.'];
$validator = Validator::make(request::all(), $rules, $messages);
if ($validator->fails()) {
return redirect('/admin/article/new')->withInput($request::all())->withErrors($validator);
}
$all = $request::all();
$title = $all["title"];
$alias = $this->remove_utf8($title);
$summary = $all["summary"];
$content = $all["articleContent"];
$category = $all["category"];
$author = $all["author"];
$data = array("title" => $title, "alias" => $alias, "summary" => $summary, "content" => $content, "category_id" => $category, "author" => $author, "status" => 1, "creator_id" => Auth::user()["id"], "created_date" => date("Y-m-d H:i:s"));
Article::insert($data);
return view("admin.article.new");
}
示例7: postRegister
public function postRegister(request $request)
{
$rules = array('number' => 'required|alpha|min:2|unique:users', 'name' => 'required|alpha|min:2', 'password' => 'required|alpha_num|between:6,8|confirmed', 'password_confirmation' => 'required|alpha_num|between:6,8');
$validator = Validator::make($request->all(), $rules);
if ($validator->passes()) {
$user = new User();
$user->number = $request['number'];
$user->name = $request['name'];
$user->phone = $request['phone'];
$user->industry = $request['industry'];
$user->company = $request['company'];
$user->address = $request['address'];
$user->qq = $request['qq'];
$user->email = $request['email'];
$user->cnumber = $request['cnumber'];
$user->password = Hash::make($request['password']);
$user->save();
return Redirect::to('auth/login')->with('message', '注册成功,立即登录体验!');
} else {
return Redirect::to('/dream')->withErrors($validator)->with('message', '请您正确填写下列数据');
}
}
示例8: 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);
}
示例9: store
/**
* 存储回复.
*
* @param request $request request
* @param int $accountId accountId
*
* @return Reply 模型
*/
public function store($request, $accountId)
{
$reply = new $this->model();
$input = $request->all();
$replies = $input['replies'];
$input['content'] = $this->saveRepliesToEvent($replies, $accountId);
$input['account_id'] = $accountId;
$input['type'] = Reply::TYPE_KEYWORDS;
return $this->savePost($reply, $input);
}
示例10: post_evaluate
public function post_evaluate(\Illuminate\Http\Request $request, $qr_id)
{
// Validate form
$this->validate($request, ['quote_id' => 'required'], $messages = array('quote_id.required' => 'You should choose a Supplier for creating a Quote'));
$quote_request = QuoteRequest::find($qr_id);
$quantities = $quote_request->first_quote()->quantities();
$input = request::all();
$quote_id = $input['quote_id'];
$quote = Quote::find($quote_id);
//echo "<pre>";
//echo "Selecting Quote ID $quote_id for Quote Request $qr_id\n";
foreach ($quote_request->qris as $qri) {
$qty = $qri["quantity"];
$qi = QuoteItem::where("quantity", "=", $qty)->where("quote_id", "=", $quote_id)->first();
//print("QRI: " . $qri["quantity"] . ": " . $qri["price"]."\n");
if ($qi == null) {
//print("Could not find quote item for Quantity $qty\n");
$qri["price"] = 0;
$qri["gst"] = 0;
$qri["total"] = 0;
$qri["unit_price"] = 0;
$qri->save();
} else {
$qri["price"] = $qi["total_net"];
$qri["gst"] = $qri["price"] * 0.1;
$qri["total"] = $qri["price"] + $qri["gst"];
$qri["unit_price"] = $qri["total"] / $qri["quantity"];
$qri->save();
}
}
$quote_request = QuoteRequest::find($qr_id);
$quote_request->quote_id = $input['quote_id'];
$quote_request->save();
// delete Quote PDF if exists
$path = 'quotes/' . $qr_id . '.pdf';
if (file_exists($path)) {
unlink($path);
}
return redirect('evaluate/' . $qr_id);
}
示例11: getLinkedStoreOffers
public function getLinkedStoreOffers(request $request)
{
$rules = array('store_token' => 'required');
$Validator = $this->customValidator($request->all(), $rules, array());
if ($Validator->fails()) {
return response()->json(['response_code' => 'ERR_RULES', 'messages' => $Validator->errors()->all()], 400);
}
$store_id = Crypt::decrypt($request->input('store_token'));
if (!$this->checkUserHasStorePermission($store_id)) {
return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
}
return response()->json(['response_code' => 'RES_OFF', 'messages' => 'Offers', 'data' => Offers::with('votesCount', 'Store.Address.Area')->where('store_id', $store_id)->get()]);
}
示例12: update
/**
* Update a specified raid.
*
* @param Request $request
* @param int $id
* @return json
*/
public function update(request $request, $id)
{
$raid = Auth::user()->raids()->find($id);
if ($raid->update($request->all())) {
return ['error' => false, 'raid' => $raid];
}
return ['error' => true];
}
示例13: updateStore
public function updateStore(request $request)
{
$validator = Validator::make($request->all(), ['store_id' => 'required', 'name' => 'required|max:255', 'address' => 'required|min:10', 'code' => 'required', 'cost' => 'required', 'timer' => 'required|max:200', 'is_active' => 'required']);
$input = $request->only('store_id');
$inputVal = $request->only('name', 'code');
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
$store = Store::find($input['store_id']);
if ($inputVal['name'] != $store->name) {
$validator = Validator::make($request->all(), ['name' => 'unique:stores']);
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
}
if ($inputVal['code'] != $store->code) {
$validator = Validator::make($request->all(), ['code' => 'unique:stores']);
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
}
foreach ($request->only('name', 'address', 'code', 'cost', 'timer', 'is_active') as $key => $value) {
$store->{$key} = $value;
}
if ($request->hasFile('offer_image')) {
$image = $request->file('offer_image');
$imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/stores/' . $imageName);
Image::make($image->getRealPath())->resize(280, 240)->save($path);
$store->offer_image = $imageName;
}
$store->save();
return redirect('admin/store/' . $input['store_id']);
}
示例14: 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']);
}
示例15: 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]);
}