本文整理汇总了PHP中Illuminate\Http\Request::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::exists方法的具体用法?PHP Request::exists怎么用?PHP Request::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOAuth
/**
* Handle OAuth login.
*
* @param string $provider
*
* @return \Laravel\Lumen\Http\Redirector|\Illuminate\Http\RedirectResponse
*/
public function getOAuth($provider)
{
switch ($provider) {
case 'google':
case 'facebook':
if (!$this->request->exists('code')) {
return redirect('/login')->withErrors(trans('passwords.oauth_failed'));
}
break;
case 'twitter':
if (!$this->request->exists('oauth_token') || !$this->request->exists('oauth_verifier')) {
return redirect('/login')->withErrors(trans('passwords.oauth_failed'));
}
break;
}
/** @var SocialiteUser $userInfo */
$userInfo = $this->socialite->driver($provider)->user();
if ($this->registrar->loginViaOAuth($userInfo, $provider)) {
return ['message' => 'Login successful'];
}
throw new LoginNotValidException(trans('passwords.oauth_failed'));
}
示例2: postAction
public function postAction(Request $request)
{
if ($request->exists('btn-multiupload')) {
echo '<pre>', print_r($request->file('file')), '</pre>';
echo '<pre>', print_r($request->input()), '</pre>';
$file = $request->file('file');
$path = 'images/uploads';
$filename = $file->getClientOriginalName();
$file->move('images/uploads', $file->getClientOriginalName());
$image = new Images();
$image->image_name = $filename;
$image->save();
echo 'Uploaded';
}
if ($request->exists('btn-upload')) {
$file = $request->file('uploader');
$path = 'images/uploads';
$filename = $file->getClientOriginalName();
$file->move('images/uploads', $file->getClientOriginalName());
$image = new Images();
$image->image_name = $filename;
$image->save();
echo 'Uploaded';
}
//return redirect()->back();
}
示例3: updateBusStop
public function updateBusStop($halteId, Request $request)
{
$busStopModel = new BusStop();
$response = array();
try {
$response['code'] = 400;
$response['data']['msg'] = 'noting updated, please check if your request is correct';
if ($request->exists('nama_halte')) {
$busStopModel->where('halte_id', '=', $halteId)->update(['nama_halte' => $request->input('nama_halte')]);
$response['code'] = 200;
$response['data']['msg'] = 'Nama halte has been updated';
}
if ($request->exists('alamat_halte')) {
$busStopModel->where('halte_id', '=', $halteId)->update(['lokasi_halte' => $request->input('alamat_halte')]);
$response['code'] = 200;
$response['data']['msg'] = 'Lokasi halte has been updated';
}
if ($request->exists('latitude')) {
$busStopModel->where('halte_id', '=', $halteId)->update(['latitude' => $request->input('latitude')]);
$response['code'] = 200;
$response['data']['msg'] = 'latitude halte has been updated';
}
if ($request->exists('longitude')) {
$busStopModel->where('halte_id', '=', $halteId)->update(['longitude' => $request->input('longitude')]);
$response['code'] = 200;
$response['data']['msg'] = 'longitude halte has been updated';
}
} catch (\Exception $e) {
$response['code'] = 500;
$response['data']['msg'] = 'internal error, please try again later or contact administrator';
}
header("Access-Control-Allow-Origin: *");
return response()->json($response);
}
示例4: handle
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->exists('g-recaptcha-response')) {
$recaptcha = new ReCaptcha(Settings::get('secret_key'));
/**
* Verify the reponse, pass user's IP address
*/
$response = $recaptcha->verify($request->input('g-recaptcha-response'), $request->ip());
/**
* Fail, if the response isn't OK
*/
if (!$response->isSuccess()) {
if ($request->ajax()) {
throw new AjaxException($response->getErrorCodes());
} else {
foreach ($response->getErrorCodes() as $code) {
Flash::error($code);
}
return redirect()->back()->withInput();
}
}
}
/**
* Handle request
*/
return $next($request);
}
示例5: getParagraphCount
/**
* Returns the number of paragraphs to be generated by reading from the
* value from the $_POST superglobal. If the value is not set or is set to
* an invalid value it uses the default value.
*
* @param Request $request The request object posted by the user
* @return int The number of paragraphs to be generated based on $_POST
* settings.
*/
private function getParagraphCount($request)
{
if ($request->exists(self::PARAGRAPH_COUNT_KEY)) {
return (int) $request->get(self::PARAGRAPH_COUNT_KEY);
} else {
return self::DEFAULT_PARAGRAPH_COUNT;
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$projectId = $request->exists('project_id') ? $request->get('project_id') : 0;
if ($this->service->checkProjectPermissions($projectId) == false) {
return ['error' => 'Access forbidden'];
}
return $this->service->addMember($request->all());
}
示例7: store
public function store(Request $request, ImageUploader $uploader)
{
$file = $request->file('upload');
$url = $uploader->upload($file);
if ($request->exists('json')) {
return ['uploaded' => 1, 'url' => $url];
}
return view('ckeditor::upload', ['url' => $url, 'funcNum' => (int) $request->input('CKEditorFuncNum')]);
}
示例8: index
public function index(Request $request)
{
$stations = \App\Station::with('tags');
if ($request->exists('tag_id')) {
$stations = $stations->whereHas('tags', function ($q) use($request) {
$q->whereRaw('`tags`.`id` = ' . $request->get('tag_id', 0));
});
}
if ($request->user()->isAdmin()) {
if ($request->exists('user_id')) {
$stations = $stations->where('user_id', $request->get('user_id', 0));
}
$stations = $stations->get();
} else {
$stations = $stations->where('user_id', $request->user()->id)->get();
}
return view('backend.stations.index', compact('stations'));
}
示例9: postAction
public function postAction(Request $request)
{
$arr = $request->get('id');
if ($request->exists('delete') && $arr) {
foreach ($arr as $key => $id) {
Users::where('id', $id)->delete();
}
}
return redirect()->back();
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Comment $comment, Request $request)
{
$validator = Validator::make($request->all(), ['published' => 'sometimes|date', 'title' => 'sometimes|max:255|min:3', 'content' => 'sometimes', 'group' => 'sometimes|integer', 'comments' => 'sometimes']);
if ($validator->passes()) {
// TBD check user has write access to group
$comment = $comment->comment;
$comment->title = $request->exists('title') ? $request->title : $comment->title;
$comment->content = $request->exists('content') ? $request->content : $comment->content;
$comment->allow_comments = $request->exists('comments') ? (bool) $request->comments : $comment->allow_comments;
$comment->group_id = $request->exists('group') ? (bool) $request->group : $comment->group_id;
$comment->save();
if ($comment->save()) {
return $this->respondWithItem($comment, new PostTransformer());
} else {
return $this->errorInternal('Unable to update comment');
}
} else {
return $this->errorValidation($validator->messages);
}
}
示例11: saveAddress
public function saveAddress(Request $request, \CodeCommerce\AddressUser $addressUser)
{
$userId = $request->get('user_id');
if ($request->exists('delivery')) {
$delivery = $request->get('delivery');
$addressUser->create(['user_id' => $userId, 'type' => 'delivery', 'city' => $delivery['city'], 'address' => $delivery['address'], 'state' => $delivery['state'], 'country' => $delivery['country'], 'zipcode' => $delivery['zipcode']]);
}
if ($request->exists('billing')) {
$billing = $request->get('billing');
$addressUser->create(['user_id' => $userId, 'type' => 'billing', 'city' => $billing['city'], 'address' => $billing['address'], 'state' => $billing['state'], 'country' => $billing['country'], 'zipcode' => $delivery['zipcode']]);
}
switch ($request->get('redirect_to')) {
case 'checkout':
return redirect()->route('checkout.orderPlace');
break;
default:
return redirect()->route('account');
break;
}
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Illuminate\Session\TokenMismatchException
*/
public function handle($request, Closure $next)
{
if ('testing' === App::environment() && $request->exists('_token')) {
$input = $request->all();
$input['_token'] = $request->session()->token();
$request->replace($input);
}
if ($this->isReading($request) || $this->shouldPassThrough($request) || $this->tokensMatch($request)) {
return $this->addCookieToResponse($request, $next($request));
}
throw new TokenMismatchException();
}
示例13: tokenize
public function tokenize(\Illuminate\Http\Request $request)
{
if (!$request->exists('code')) {
return redirect("/");
}
$params = ['client_id' => env('VK_APP_ID'), 'client_secret' => env('VK_APP_KEY'), 'code' => $request->get('code'), 'redirect_uri' => env('VK_APP_REDIRECT')];
$curl = new Curl(null, $params, [], "https://oauth.vk.com/access_token");
$vkResponse = $curl->all();
Session::put('vk_expires', $vkResponse->expires_in);
Session::put('vk_token', $vkResponse->access_token);
Session::put('vk_userid', $vkResponse->user_id);
return redirect('/');
}
示例14: grid
public function grid(Request $request)
{
if ($request->ajax() && $request->exists('req')) {
$req = json_decode($request->get('req'));
$perPage = $req->page->perPage;
$from = $perPage * ($req->page->currentPage - 1);
//--< to get users from company
$query = User::distinct();
if (!is_null($req->sort)) {
foreach ($req->sort as $key => $value) {
$query->orderBy($key, $value);
}
}
if (!is_null($req->filter)) {
foreach ($req->filter as $key => $value) {
switch ($value->operator) {
case 'IsEqualTo':
$query->where($key, '=', $value->operand1);
break;
case 'IsNotEqualTo':
$query->where($key, '<>', $value->operand1);
break;
case 'StartWith':
$query->where($key, 'LIKE', $value->operand1 . '%');
break;
case 'Contains':
$query->where($key, 'LIKE', '%' . $value->operand1 . '%');
break;
case 'DoesNotContains':
$query->where($key, 'NOT LIKE', '%' . $value->operand1 . '%');
break;
case 'EndsWith':
$query->where($key, 'LIKE', '%' . $value->operand1);
break;
case 'Between':
$query->whereBetween($key, array($value->operand1, $value->operand2));
break;
}
}
}
$total = $query->count();
$query->take($perPage)->skip($from);
$data = $query->get(['users.id as users.id', 'users.name as users.name', 'users.email as users.email', 'users.mobile as users.mobile', 'users.description as users.description', 'users.created_at as users.created_at', 'users.updated_at as users.updated_at']);
$totalPage = ceil($total / $perPage);
$countDataPerPage = count($data);
$page = array("currentPage" => $req->page->currentPage, "lastPage" => $totalPage, "total" => $total, "from" => $from + 1, "count" => $countDataPerPage, "perPage" => $perPage);
$result = ['data' => $data, 'page' => $page];
// dd($result);
return json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
}
示例15: grid
public function grid(Request $request)
{
if ($request->ajax() && $request->exists('req')) {
$req = json_decode($request->get('req'));
$perPage = 10;
$from = $perPage * ($req->page->currentPage - 1);
$query = Newsletter::join('users', 'newsletters.user_id', '=', 'users.id')->select(['newsletters.id as newsletters.id', 'users.full_name', 'newsletters.title as newsletters.title', 'newsletters.content as newsletters.content', 'newsletters.receivers as newsletters.receivers', 'newsletters.created_at as newsletters.created_at']);
if (!is_null($req->sort)) {
foreach ($req->sort as $key => $value) {
$query->orderBy($key, $value);
}
}
if (!is_null($req->filter)) {
foreach ($req->filter as $key => $value) {
switch ($value->operator) {
case 'IsEqualTo':
$query->where($key, '=', $value->operand1);
break;
case 'IsNotEqualTo':
$query->where($key, '<>', $value->operand1);
break;
case 'StartWith':
$query->where($key, 'LIKE', $value->operand1 . '%');
break;
case 'Contains':
$query->where($key, 'LIKE', '%' . $value->operand1 . '%');
break;
case 'DoesNotContains':
$query->where($key, 'NOT LIKE', '%' . $value->operand1 . '%');
break;
case 'EndsWith':
$query->where($key, 'LIKE', '%' . $value->operand1);
break;
case 'Between':
$query->whereBetween($key, array($value->operand1, $value->operand2));
break;
}
}
}
$total = $query->count();
$query->take($perPage)->skip($from);
$data = $query->get();
$totalPage = ceil($total / $perPage);
$countDataPerPage = count($data);
$page = array("currentPage" => $req->page->currentPage, "lastPage" => $totalPage, "total" => $total, "from" => $from + 1, "count" => $countDataPerPage, "perPage" => $perPage);
$result = ['data' => $data, 'page' => $page];
return json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
}
}