本文整理汇总了PHP中Illuminate\Support\Facades\Request类的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:DinanathThakur,项目名称:Flash-Sale-Ecommerce-Portal-PHP,代码行数:7,代码来源:CacheFilter.php
示例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 = '[email protected]';
$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]);
}
开发者ID:krysmunialo,项目名称:sendy---request_delivery,代码行数:59,代码来源:OrdersController.php
示例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;
}
}
开发者ID:giecocartagena,项目名称:gieco,代码行数:11,代码来源:UsuarioController.php
示例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());
}
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:7,代码来源:WebhookControllerTest.php
示例5: current
public function current($uri = false)
{
if ($uri) {
return Request::url();
}
return Request::fullUrl();
}
开发者ID:parabol,项目名称:laravel-cms,代码行数:7,代码来源:Url.php
示例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();
}
开发者ID:quentin-sommer,项目名称:WebTv,代码行数:25,代码来源:AdminController.php
示例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;
}
开发者ID:robbytaylor,项目名称:boom-core,代码行数:18,代码来源:Str.php
示例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();
});
}
开发者ID:uniacid,项目名称:visitor-log,代码行数:38,代码来源:VisitorLogServiceProvider.php
示例9: handle
/**
* Handle the specified event.
*/
public function handle()
{
$isOnAdmin = Request::is('admin') || Request::is('admin/*');
if (!$isOnAdmin) {
Visitor::track();
}
}
开发者ID:mrzeta,项目名称:admin,代码行数:10,代码来源:VisitorObserver.php
示例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');
}
开发者ID:amittier5,项目名称:miramix,代码行数:35,代码来源:MyController.php
示例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!');
}
开发者ID:RhezaBoge,项目名称:temuguna,代码行数:14,代码来源:controller_media_manager.php
示例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();
}
开发者ID:siparker,项目名称:ribbbon,代码行数:36,代码来源:FilesController.php
示例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!');
}
开发者ID:RhezaBoge,项目名称:temuguna,代码行数:14,代码来源:controller_project_issue.php
示例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;
}
开发者ID:fabriciorabelo,项目名称:laravel-theme,代码行数:39,代码来源:AssetContainer.php
示例15: update
public function update($id)
{
$clockin = UserClockin::find($id);
$data = Request::all();
$clockin->fill($data);
$clockin->save();
}
开发者ID:staciewilhelm,项目名称:denver-member-tracking,代码行数:7,代码来源:UserClockinsController.php
示例16: createUsers
public function createUsers()
{
$inputs = Request::all();
$userTypes = Request::get('userType');
// Checking permission of user before creating new users
$emails = json_decode(Request::input('users'));
foreach ($emails as $email) {
Log::info('username - ' . $email);
$password = str_random(10);
DB::table('users')->insert(['name' => $email, 'email' => $email, 'password' => bcrypt($password), 'type' => 'caller']);
foreach ($userTypes as $userType) {
// Making a 'userType' user
$user = \App\User::where('name', '=', $email)->first();
$caller = \App\Role::where('name', '=', $userType)->first();
// role attach alias
$user->attachRole($caller);
// parameter can be an Role object, array, or id
}
$data = array('name' => $email, 'username' => $email, 'password' => $password);
// Would sent a link to the user to activate his account
// $this->sendLink($email);
// \Mail::send('mail.email', $data, function ($message) use ($data) {
// $message->subject('Login Details ')
// ->to('[email protected]');
// });
}
return view('create-users', ['page' => 'create-users']);
}
开发者ID:manishdwibedy,项目名称:SCaller,代码行数:28,代码来源:CreateUsers.php
示例17: build
/**
* Build a navigation menu from an array with the following structure: <br/>
* $navbar = array( <br/>
* ['url'=>'url', 'textkey'=>'public.title', 'nopattern' => true ], <br/>
* ['url'=>'url/products', 'textkey'=>'public.products.title' ], <br/>
* ['url'=>'url/clients', 'textkey'=>'public.clients.title', 'icon' => 'fa-users' ], <br/>
*);
*/
public static function build(array $_menu, $_currentLocale = '', $_addItemClass = '')
{
$str = '';
foreach ($_menu as $key => $option) {
$icon = isset($option['icon']) ? '<i class="fa ' . $option['icon'] . ' fa-fw"></i> ' : '';
if (isset($option['divider'])) {
$str .= '<li class="divider"></li>';
} else {
if (isset($option['submenu'])) {
$requestPattern = $_currentLocale . ($option['url'] == '' ? '' : '/' . $option['url'] . '*');
$isActive = '';
$isOpenned = '';
if (Request::is($requestPattern)) {
$isActive = ' active';
$isOpenned = ' in';
}
$str .= '<li class="' . $_addItemClass . ' list-toggle' . $isActive . '">' . '<a class="accordion-toggle" href="#collapse-' . $key . '" data-toggle="collapse">' . $icon . trans($option['textkey']) . '</a>' . '<ul id="collapse-' . $key . '" class="collapse' . $isOpenned . '">' . self::build($option['submenu'], $_currentLocale) . '</ul>' . '</li>';
} else {
$submenusPattern = isset($option['nopattern']) ? '' : '*';
$requestPattern = $_currentLocale . ($option['url'] == '' ? '' : '/' . $option['url'] . $submenusPattern);
//$requestPattern = $_currentLocale . $option['url'] . $submenusPattern;
$isActive = \Request::is($requestPattern) ? ' active' : '';
$str .= '<li class="' . $_addItemClass . $isActive . '">' . '<a href="' . \URL::to($option['url']) . '">' . $icon . trans($option['textkey']) . '</a>' . '</li>';
}
}
}
return $str;
}
开发者ID:ajgallego,项目名称:laravel-helpers,代码行数:36,代码来源:HelpMenu.php
示例18: getProgrammes
/**
* Get a collection of programmes listed by letter, using a cached record if it exists
* @param string $letter The letter for which to query the programmes
* @return \Illuminate\Support\Collection
*/
public function getProgrammes($letter)
{
$page = Request::get('page', 1);
return $this->cache->remember("bbc.programmes.{$letter}.page.{$page}", \Config::get('cache.remember_time'), function () use($letter) {
return $this->bbc_api_client->getProgrammes($letter);
});
}
开发者ID:harrygr,项目名称:azlisting,代码行数:12,代码来源:CacheBbcApiClient.php
示例19: getObject
/**
* @return Model
*/
public function getObject()
{
// Get ID from url segments.
$segments = Request::segments();
$id = end($segments);
return $this->getQuerySet()->where($this->lookupField, $id)->firstOrFail();
}
开发者ID:kalaomer,项目名称:kahire,代码行数:10,代码来源:GenericViewSet.php
示例20: log
/**
* Create an activity log entry.
*
* @param mixed
* @return boolean
*/
public static function log($data = array())
{
if (is_object($data)) {
$data = (array) $data;
}
if (is_string($data)) {
$data = array('action' => $data);
}
$user = Auth::user();
$activity = new static();
$activity->user_id = isset($user->id) ? $user->id : 0;
$activity->content_id = isset($data['contentID']) ? $data['contentID'] : 0;
$activity->content_type = isset($data['contentType']) ? $data['contentType'] : "";
$activity->action = isset($data['action']) ? $data['action'] : "";
$activity->description = isset($data['description']) ? $data['description'] : "";
$activity->details = isset($data['details']) ? $data['details'] : "";
//set action and allow "updated" boolean to replace activity text "Added" or "Created" with "Updated"
if (isset($data['updated'])) {
if ($data['updated']) {
$activity->description = str_replace('Added', 'Updated', str_replace('Created', 'Updated', $activity->description));
$activity->action = "Updated";
} else {
$activity->action = "Created";
}
}
if (isset($data['deleted']) && $data['deleted']) {
$activity->action = "Deleted";
}
//set developer flag
$activity->developer = !is_null(Session::get('developer')) ? true : false;
$activity->ip_address = Request::getClientIp();
$activity->user_agent = $_SERVER['HTTP_USER_AGENT'];
$activity->save();
return true;
}
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:41,代码来源:Activity.php
注:本文中的Illuminate\Support\Facades\Request类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论