本文整理汇总了PHP中Illuminate\Http\Request::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::all方法的具体用法?PHP Request::all怎么用?PHP Request::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process video upload
*
* @param \Illuminate\Http\Request $request The form with the needed data
* @return \Illuminate\Http\RedirectResponse
*/
public function process(Request $request)
{
//validation rules
$rules = ['title' => 'required', 'category_list' => 'required', 'user_id' => 'required', 'video' => 'isneededvideo'];
//validation messages
$msgs = ['title.required' => 'A cím kitöltése kötelező!', 'category_list.required' => 'A kategória kiválasztása kötelező!', 'user_id.required' => 'A szerző kiválasztása kötelező!', 'video.required' => 'Videó nélkül nincs mit feltölteni!', 'isneededvideo' => 'A videónak mp4 vagy webm formátumúnak kell lennie!'];
\Validator::extend('isneededvideo', function ($attr, $value, $params) {
return $value->getMimeType() == 'video/mp4' || $value->getMimeType() == 'video/webm';
});
$validator = \Validator::make($request->all(), $rules, $msgs);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator->errors())->withInput($request->all());
}
//ease up coding with some shortcuts
$file = $request->file('video');
$extension = strtolower($file->getClientOriginalExtension());
$video = \App\Models\Video::create($request->except('video', 'category_list'));
//set video filename
$video->video = $video->getKey() . '.' . $extension;
//move video file
$file->move(public_path() . '/videos/', $video->video);
//save object
$video->save();
//sync pivot
$video->categories()->sync(array_filter($request->input('category_list')));
//do the capture
$this->capture($video);
return redirect('/');
}
示例2: makeOrder
public function makeOrder(Request $request)
{
$validator = $this->validator($request->all());
if (!isset(\Auth::user()->name)) {
if ($validator->fails()) {
return redirect('order/save')->withErrors($validator)->withInput();
}
}
$input = $request->all();
$cartCollection = Cart::getContent();
$products = $cartCollection->toArray();
$productId = array_keys($products);
if (isset(\Auth::user()->name)) {
$authUser = \Auth::user();
$orderSave = Order::create(['telephone' => $authUser->telephone, 'user_name' => $authUser->name, 'email' => $authUser->email, 'adress' => $authUser->adress, 'town' => $authUser->town, 'comment' => $input['comment']]);
} else {
$orderSave = Order::create(['telephone' => $input['telephone'], 'user_name' => $input['name'], 'email' => $input['email'], 'adress' => $input['adress'], 'town' => $input['town'], 'comment' => $input['comment']]);
}
$order = Order::find($orderSave->id);
$order->product()->attach($productId);
foreach ($productId as $rm) {
Cart::remove($rm);
}
return redirect(LaravelLocalization::setLocale() . "/")->with('msg', 'Направихте успешна поръчка. Ще се свържем скоро.');
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
// error_log("------------------------------------------------------");
$Mailer = new Email();
$Mailer->email = $request['email'];
/* $validator class with method fails() */
$validator = Validator::make($request->all(), ['email' => 'required|email']);
/* $isNewEmail =
true: no email found in db
false: duplicate email found in db
*/
$isNewEmail = collect($Mailer->where('email', $Mailer->email)->get())->isEmpty() ? true : false;
if ($validator->fails()) {
error_log(json_encode(['error' => ['invalid_email' => $request->all()]]));
return response()->json(['error' => 'E-mail is invalid'])->setCallback($request->input('callback'));
} elseif (!$isNewEmail) {
error_log(json_encode(['error' => ['duplicate_email' => $request->all()]]));
return response()->json(['error' => 'E-mail is marked as being subscribed'])->setCallback($request->input('callback'));
return redirect('/')->withErrors($validator)->withInput();
} else {
error_log(json_encode(['mailer' => ['newEmail' => $Mailer]]));
// soon
$Scribe = $this->subscribe($Mailer->email);
// soon
error_log(json_encode(['scribe' => $Scribe]));
$Mailer->save();
return response()->json(['success' => true])->setCallback($request->input('callback'));
}
}
示例4: postPokaz
public function postPokaz(Request $request)
{
if (Session::has('nls')) {
$tar = Session::get('tar');
$nls = Session::get('nls');
if ($tar == 1) {
$messages = array('required' => Lang::get('book.nls_required'), 'numeric' => Lang::get('book.nls_numeric'));
$v = Validator::make($request->all(), Geng::$rules['t1'], $messages);
if ($v->fails()) {
return redirect()->back()->withInput()->withErrors($v);
} else {
$kontr_d = $request->input('t1');
Pokaz::create(array('kontr_pk' => $kontr_d, 'nls' => $nls));
return Redirect('/input/pokaz')->withAlert(Lang::get('book.pok_save'));
}
} else {
$messages = array('required' => Lang::get('book.nls_required'), 'numeric' => Lang::get('book.nls_numeric'));
$v = Validator::make($request->all(), Geng::$rules['t2'], $messages);
if ($v->fails()) {
return Redirect('/input/pokaz')->withInput()->withErrors($v);
} else {
$kontr_d = Input::get('t1');
$kontr_n = Input::get('t2');
Pokaz::create(array('kontr_pk' => $kontr_d + $kontr_n, 'd_pok' => $kontr_d, 'n_pok' => $kontr_n, 'nls' => $nls));
return Redirect('/input/pokaz')->withAlert(Lang::get('book.pok_save'));
}
}
}
}
示例5: login
/**
* 用户通过邮箱和密码进行登录操作
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function login(Request $request)
{
//获取当前访问的全部的地址
$request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
//验证参数
$validator = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
//验证参数完整性
if ($validator->fails()) {
// var_dump($validator);
$error = $validator->errors()->all();
//写入日志
Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
//返回错误信息
return Error::returnError($request_url, 1001);
}
$email = $request->get('email');
$password = $request->get('password');
//检查有没有
$user_model = User::checkUserLogin($email, $password);
if ($user_model == false) {
return Error::returnError($request_url, 2001);
}
//更新token
$token = User::updateToken($user_model);
//返回对应的结果
$json_arr = ['request' => $request_url, 'ret' => User::getUserInfo($user_model->id), 'token' => $token];
return Common::returnResult($json_arr);
}
示例6: store
public function store(Request $request)
{
Validator::extend('not_contains', function ($attribute, $value, $parameters) {
// Banned words
$words = array('undefined');
foreach ($words as $word) {
if (stripos($value, $word) !== false) {
return false;
}
}
return true;
});
$messages = array('not_contains' => 'The :attribute is required');
$validator = Validator::make($request->all(), array('name' => 'required|unique:collections|min:3|not_contains'), $messages);
if ($validator->fails()) {
return $validator->messages();
} else {
$user = Auth::user();
$user_id = $user['id'];
$collection = Collection::create($request->all());
$collection->created_by = $user_id;
$collection->approved = False;
$collection->slug = str_slug($collection->name . '-' . $collection->id, "-");
$collection->save();
return response()->json(['status' => 'success', 'data' => $collection]);
}
}
示例7: validate
/**
* Checks the steam login
*
* @return bool
*/
public function validate()
{
if ($this->request->has('openid_assoc_handle') && $this->request->has('openid_signed') && $this->request->has('openid_sig')) {
$get = $this->request->all();
try {
$params = array('openid.assoc_handle' => $get['openid_assoc_handle'], 'openid.signed' => $get['openid_signed'], 'openid.sig' => $get['openid_sig'], 'openid.ns' => 'http://specs.openid.net/auth/2.0');
$signed = explode(',', $get['openid_signed']);
foreach ($signed as $item) {
$val = $get['openid_' . str_replace('.', '_', $item)];
$params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($val) : $val;
}
$params['openid.mode'] = 'check_authentication';
$data = http_build_query($params);
$context = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Accept-language: en\r\n" . "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n", 'content' => $data)));
$result = file_get_contents(self::OPENID_URL, false, $context);
preg_match("#^http://steamcommunity.com/openid/id/([0-9]{17,25})#", $get['openid_claimed_id'], $matches);
$this->steamId = is_numeric($matches[1]) ? $matches[1] : 0;
$this->parseInfo();
$response = preg_match("#is_valid\\s*:\\s*true#i", $result) == 1 ? true : false;
} catch (Exception $e) {
$response = false;
}
if (is_null($response)) {
throw new Exception('The Steam login request timed out or was invalid');
}
return $response;
} else {
return false;
}
}
示例8: change_password
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function change_password(Request $request)
{
$input = $request->all();
$user = $request->user();
$user_detail = json_decode($user, true);
$user_id = $user_detail['id'];
$current_password = $input['current_password'];
$new_password = $input['new_password'];
$confirm_password = $input['confirm_password'];
$validator = Validator::make($request->all(), ['current_password' => 'required|min:6', 'new_password' => 'required|min:6', 'confirm_password' => 'required|same:new_password']);
if ($validator->fails()) {
return redirect('/change-password')->withErrors($validator)->withInput();
}
if (Hash::check(Input::get('current_password'), Auth::user()->password)) {
$user->password = bcrypt($new_password);
$user->save();
$request->session()->flash('alert-success', 'Password changed successful.');
return view("auth/change_password");
} else {
return Redirect::back()->withErrors(['Sorry! Your current password not match,Please try again']);
}
/* echo "<pre>";
print_r($input);
die;*/
}
示例9: DoiHinhDaiDienGV
public function DoiHinhDaiDienGV(Request $req)
{
$macb = \Auth::user()->taikhoan;
$hoten = DB::table('giang_vien')->where('macb', $macb)->value('hoten');
$post = $req->all();
$v = \Validator::make($req->all(), ['fHinh' => 'required|image']);
if ($v->fails()) {
return redirect()->back()->withErrors($v->errors());
} else {
$file = Input::file('fHinh');
// Đặt đường dẫn lưu file upload
$luuden = public_path() . '/hinhdaidien/';
// Lấy đuôi mở rộng
// $extension = Input::file('fHinh')->getClientOriginalExtension();
//Gắn đuôi mở rộng lúc nào cũng là png
$extension = "png";
// Đặt lại tên file vừa upload lên
$tachten = $this->lay_ten($hoten);
$fileName = $tachten . str_replace("/", "", str_replace(" ", "", $macb)) . '.' . $extension;
//Lưu Hình Vào CSDL
DB::table('giang_vien')->where('macb', $macb)->update(['hinhdaidien' => $fileName]);
// Chuyển file upload vào thư mục lưu trữ đã đặt trươc đó
$upload_success = $file->move($luuden, $fileName);
if ($upload_success) {
return Redirect('giangvien/doimatkhaugv')->with('message', 'Upload hình đại diện thành công!');
}
}
}
示例10: associateRelationships
/**
* Associate relationships to other table
*
* @param object $object
* @param Request $request
*/
public function associateRelationships($object, Request $request)
{
/**
* Validate user ID, if failed set to actual authorized user
*/
$validator = Validator::make($request->all(), ['user_id' => 'required|integer|min:1|exists:users,id']);
/**
* Validator fails - add actual authorized user
*/
if ($validator->fails()) {
$object->users()->associate(Auth::user()->id);
} else {
$object->users()->associate($request->input('user_id'));
}
/**
* Validate image ID, if failed set to default
*/
$validator = Validator::make($request->all(), ['image_id' => 'integer|min:1|exists:image,id']);
/**
* Validator fails - nothing to do
*/
if ($validator->fails()) {
} else {
$object->images()->associate($request->input('image_id'));
}
}
示例11: create
/**
* post的方式添加一条记录
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
$request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
//验证参数
$validator = Validator::make($request->all(), ['name' => 'required|max:255']);
//验证参数完整性
if ($validator->fails()) {
$error = $validator->errors()->all();
//写入日志
Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
//返回错误信息
return Error::returnError($request_url, 1001);
}
//验证token
// $user_id=Common::validateToken($request->get('token'));
//
// if($user_id == false){
// return Error::returnError($request_url,2002);
// }
$name = $request->get('name');
//写入操作
$add = Task::addTask($name);
$info = Task::getTaskInfo($add);
//返回对应的结果
$json_arr = ['request' => $request_url, 'ret' => $info];
return Common::returnResult($json_arr);
}
示例12: getRequestAsArray
public function getRequestAsArray($method)
{
if ($old = $this->request->old()) {
return $old;
}
return $this->request->all();
}
示例13: store
/**
* New status comment
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$this->commentForm->validate($request->all());
$input = array_add($request->all(), 'user_id', Auth::id());
$this->statusRepo->leaveComment($input);
return back();
}
示例14: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$body = $request->all();
$status = new Status($request->all());
\Auth::user()->statuses()->save($status);
return \Redirect::back();
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$property = Property::findOrFail($request->all()['property_id']);
$rental = ['id' => $request->all()['rental_id'], 'dailyAmount' => $request->all()['rental_dailyAmount'], 'from' => $request->all()['rental_from'], 'to' => $request->all()['rental_to'], 'media' => self::stripMedia($request)];
Rental::store($rental['dailyAmount'], $rental['from'], $rental['to'], $property, $rental['media'], $rental['id']);
return Redirect::route('rental.index');
}