本文整理汇总了PHP中Illuminate\Support\Facades\Request类的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
public function put(Route $route, Request $request, Response $response)
{
$key = $this->makeCacheKey($request->url());
if (!Cache::has($key)) {
Cache::put($key, $response->getContent(), 60);
}
}
示例2: toApi
public function toApi(Request $request)
{
$client = new \GuzzleHttp\Client();
$input = $request::all();
$command = 'request';
$api_key = 'MjuhMtfAAfvJqzbnWFLA';
// $api_key = 'mysendykey';
$api_username = 'chris-stop';
// $api_username = 'mysendyusername';
$from_name = 'Chris Munialo';
$from_lat = $input['lat'];
$from_long = $input['lng'];
$from_description = '';
$to_name = 'TRM';
$to_lat = $input['lat1'];
$to_long = $input['lng1'];
$to_description = '';
$recepient_name = 'John';
$recepient_phone = '0710000000';
$recepient_email = 'John@doe.com';
$pick_up_date = '2016-04-20 12:12:12';
$status = false;
$pay_method = 0;
$amount = 10;
$return = true;
$note = 'Sample note';
$note_status = true;
$request_type = 'quote';
$info = ['command' => $command, 'data' => ['api_key' => $api_key, 'api_username' => $api_username, 'from' => ['from_name' => $from_name, 'from_lat' => floatval($from_lat), 'from_long' => floatval($from_long), 'from_description' => $from_description], 'to' => ['to_name' => $to_name, 'to_lat' => floatval($to_lat), 'to_long' => floatval($to_long), 'to_description' => $to_description], 'recepient' => ['recepient_name' => $recepient_name, 'recepient_phone' => $recepient_phone, 'recepient_email' => $recepient_email], 'delivery_details' => ['pick_up_date' => $pick_up_date, 'collect_payment' => ['status' => $status, 'pay_method' => $pay_method, 'amount' => $amount], 'return' => $return, 'note' => $note, 'note_status' => $note_status, 'request_type' => $request_type]]];
$clientHandler = $client->getConfig('handler');
// Create a middleware that echoes parts of the request.
$tapMiddleware = Middleware::tap(function ($request) {
$request->getHeader('Content-Type');
// application/json
$request->getBody();
// {"foo":"bar"}
});
$endpoint = 'https://developer.sendyit.com/v1/api/#request';
// $info = json_encode($info);
$client = new \GuzzleHttp\Client();
$res = $client->request('POST', $endpoint, ['json' => $info, 'handler' => $tapMiddleware($clientHandler), 'headers' => ['Accept' => 'application/json']]);
// $res->getStatusCode();
// "200"
// $res->getHeader('content-type');
// 'application/json; charset=utf8'
$pns = json_decode($res->getBody(), true);
// var_dump($pns);
// echo $pns;
// echo $pns;
// $pns= $res->getBody();
// {"type":"User"...
// Send an asynchronous request.
// $request = new \GuzzleHttp\Psr7\Request('POST', $endpoint );
// $promise = $client->sendAsync($request)->then(function ($response) {
// $response->getBody();
// });
// $promise->wait();
return view('orders.new', ['pns' => $pns]);
}
示例3: destroy
public function destroy($id, Request $request)
{
//return $id;
//Categoria::destroy($id);
$usuario = User::find($id);
$usuario->delete();
$message = $usuario->name . ' fue eliminado de la base de datos';
if ($request->ajax()) {
return $message;
}
}
示例4: testNormalResponseIsReturnedIfMethodIsMissing
public function testNormalResponseIsReturnedIfMethodIsMissing()
{
Request::shouldReceive('getContent')->andReturn(json_encode(['type' => 'foo.bar', 'id' => 'event-id']));
$controller = new WebhookControllerTestStub();
$response = $controller->handleWebhook();
$this->assertEquals(200, $response->getStatusCode());
}
示例5: current
public function current($uri = false)
{
if ($uri) {
return Request::url();
}
return Request::fullUrl();
}
示例6: postUserSettings
public function postUserSettings()
{
$error = false;
if (Request::has('user_id')) {
$user_id = (int) Auth::user()->user_id;
$input_id = (int) Request::input('user_id');
if (Request::input('roles') === null) {
$roles = [];
} else {
$roles = Request::input('roles');
}
if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) {
$roles[] = env('ROLE_ADMIN');
$error = true;
}
$editUser = User::find(Request::input('user_id'));
$editUser->roles()->sync($roles);
$editUser->save();
$this->streamingUser->update();
}
if ($error) {
return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!');
}
return redirect()->back();
}
示例7: makeInternalLinksRelative
/**
* Make links which include the current HTTP host relative, even if the scheme doens't match.
*
* Internal links within text are stored as relative links so that if a site moves host
* or the database is copied to another site (e.g. development or staging versions)
* the links will still work correctly.
*
* @param string $text
*
* @return string
*/
public static function makeInternalLinksRelative($text)
{
if ($base = Request::getHttpHost()) {
return preg_replace("|<(.*?)href=(['\"])(https?://)" . $base . "/(.*?)(['\"])(.*?)>|", '<$1href=$2/$4$5$6>', $text);
}
return $text;
}
示例8: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app['router']->before(function ($request) {
// First clear out all "old" visitors
Visitor::clear();
$page = Request::path();
$ignore = Config::get('visitor-log::ignore');
if (is_array($ignore) && in_array($page, $ignore)) {
//We ignore this site
return;
}
$visitor = Visitor::getCurrent();
if (!$visitor) {
//We need to add a new user
$visitor = new Visitor();
$visitor->ip = Request::getClientIp();
$visitor->useragent = Request::server('HTTP_USER_AGENT');
$visitor->sid = str_random(25);
}
$user = null;
$usermodel = strtolower(Config::get('visitor-log::usermodel'));
if (($usermodel == "auth" || $usermodel == "laravel") && Auth::check()) {
$user = Auth::user()->id;
}
if ($usermodel == "sentry" && class_exists('Cartalyst\\Sentry\\SentryServiceProvider') && Sentry::check()) {
$user = Sentry::getUser()->id;
}
//Save/Update the rest
$visitor->user = $user;
$visitor->page = $page;
$visitor->save();
});
}
示例9: handle
/**
* Handle the specified event.
*/
public function handle()
{
$isOnAdmin = Request::is('admin') || Request::is('admin/*');
if (!$isOnAdmin) {
Visitor::track();
}
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$image = Input::file('image');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('uploads/img/' . $filename);
Image::make($image->getRealPath())->resize(200, 200)->save($path);
$user->image = $filename;
$user->save();
$obj = new helpers();
echo "<pre>";
print_r(Input::file('image'));
exit;
$book = Request::all();
//echo "<pre>";print_r($_FILES['image']['name']);exit;
$destinationPath = 'uploads/img/';
// upload path
$thumb_path = 'uploads/img/thumb/';
$extension = Input::file('image')->getClientOriginalExtension();
// getting image extension
$fileName = rand(111111111, 999999999) . '.' . $extension;
// renameing image
Input::file('image')->move($destinationPath, $fileName);
// uploading file to given path
$obj->createThumbnail($fileName, 300, 200, $destinationPath, $thumb_path);
$book['image'] = $fileName;
Book::create($book);
Session::flash('success', 'Upload successfully');
return redirect('image');
}
示例11: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$dataUpdate = Request::all();
$data = table_media_manager::find($id);
$data->update($dataUpdate);
return redirect('admin/media-manager')->with('warning', 'Data successfully changed!');
}
示例12: store
/**
* Upload the file and store
* the file path in the DB.
*/
public function store()
{
// Rules
$rules = array('name' => 'required', 'file' => 'required|max:20000');
$messages = array('max' => 'Please make sure the file size is not larger then 20MB');
// Create validation
$validator = Validator::make(Input::all(), $rules, $messages);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$directory = "uploads/files/";
// Before anything let's make sure a file was uploaded
if (Input::hasFile('file') && Request::file('file')->isValid()) {
$current_file = Input::file('file');
$filename = Auth::id() . '_' . $current_file->getClientOriginalName();
$current_file->move($directory, $filename);
$file = new Upload();
$file->user_id = Auth::id();
$file->project_id = Input::get('project_id');
$file->name = Input::get('name');
$file->path = $directory . $filename;
$file->save();
return Redirect::back();
}
$upload = new Upload();
$upload->user_id = Auth::id();
$upload->project_id = Input::get('project_id');
$upload->name = Input::get('name');
$upload->path = $directory . $filename;
$upload->save();
return Redirect::back();
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$dataUpdate = Request::all();
$data = table_project_issue::find($id);
$data->update($dataUpdate);
return redirect('admin/project-issue')->with('warning', 'Data successfully changed!');
}
示例14: configAssetUrl
/**
* Generate a URL to an application asset.
*
* @param string $path
* @param bool $secure
* @return string
*/
protected function configAssetUrl($path, $secure = null)
{
static $assetUrl;
// Remove this.
$i = 'index.php';
if (URL::isValidUrl($path)) {
return $path;
}
// Finding asset url config.
if (is_null($assetUrl)) {
$assetUrl = \Config::get('theme.assetUrl', '');
}
// Using asset url, if available.
if ($assetUrl) {
$base = rtrim($assetUrl, '/');
// Asset URL without index.
$basePath = str_contains($base, $i) ? str_replace('/' . $i, '', $base) : $base;
} else {
if (is_null($secure)) {
$scheme = Request::getScheme() . '://';
} else {
$scheme = $secure ? 'https://' : 'http://';
}
// Get root URL.
$root = Request::root();
$start = starts_with($root, 'http://') ? 'http://' : 'https://';
$root = preg_replace('~' . $start . '~', $scheme, $root, 1);
// Asset URL without index.
$basePath = str_contains($root, $i) ? str_replace('/' . $i, '', $root) : $root;
}
return $basePath . '/' . $path;
}
示例15: update
public function update($id)
{
$clockin = UserClockin::find($id);
$data = Request::all();
$clockin->fill($data);
$clockin->save();
}