本文整理匯總了PHP中Illuminate\Support\Facades\Request::method方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::method方法的具體用法?PHP Request::method怎麽用?PHP Request::method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Request
的用法示例。
在下文中一共展示了Request::method方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getExceptionData
private function getExceptionData($exception)
{
$data = [];
$data['host'] = Request::server('HTTP_HOST');
$data['method'] = Request::method();
$data['fullUrl'] = Request::fullUrl();
if (php_sapi_name() === 'cli') {
$data['host'] = parse_url(config('app.url'), PHP_URL_HOST);
$data['method'] = 'CLI';
}
$data['exception'] = $exception->getMessage();
$data['error'] = $exception->getTraceAsString();
$data['line'] = $exception->getLine();
$data['file'] = $exception->getFile();
$data['class'] = get_class($exception);
$data['storage'] = array('SERVER' => Request::server(), 'GET' => Request::query(), 'POST' => $_POST, 'FILE' => Request::file(), 'OLD' => Request::hasSession() ? Request::old() : [], 'COOKIE' => Request::cookie(), 'SESSION' => Request::hasSession() ? Session::all() : [], 'HEADERS' => Request::header());
$data['storage'] = array_filter($data['storage']);
$count = $this->config['count'];
$data['exegutor'] = [];
$data['file_lines'] = [];
$file = new SplFileObject($data['file']);
for ($i = -1 * abs($count); $i <= abs($count); $i++) {
list($line, $exegutorLine) = $this->getLineInfo($file, $data['line'], $i);
$data['exegutor'][] = $exegutorLine;
$data['file_lines'][$data['line'] + $i] = $line;
}
// to make Symfony exception more readable
if ($data['class'] == 'Symfony\\Component\\Debug\\Exception\\FatalErrorException') {
preg_match("~^(.+)' in ~", $data['exception'], $matches);
if (isset($matches[1])) {
$data['exception'] = $matches[1];
}
}
return $data;
}
示例2: register
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$configPath = __DIR__ . '/../config/sql-logging.php';
$this->mergeConfigFrom($configPath, 'sql-logging');
if (config('sql-logging.log', false)) {
Event::listen('illuminate.query', function ($query, $bindings, $time) {
$data = compact('bindings', 'time');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding) {
if ($binding instanceof \DateTime) {
$bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
} else {
if (is_string($binding)) {
$bindings[$i] = "'{$binding}'";
}
}
}
// Insert bindings into query
$query = str_replace(array('%', '?'), array('%%', '%s'), $query);
$query = vsprintf($query, $bindings);
$log = new Logger('sql');
$log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
// if log request data
if (config('sql-logging.log_request', false)) {
$data['request_path'] = Request::path();
$data['request_method'] = Request::method();
$data['request_data'] = Request::all();
}
// add records to the log
$log->addInfo($query, $data);
});
}
}
示例3: anyManageShop
public function anyManageShop()
{
$product_types = ProductTypes::where('hidden', 0)->orderBy('name', 'ASC')->get();
$success_msg = [];
$error_msg = [];
$rules = ['product_name' => 'required', 'product_category' => 'required', 'short_description' => 'required', 'product_description' => 'required', 'price' => 'required', 'quantity' => 'required|numeric'];
$validator = Validator::make(Input::all(), $rules);
if (Request::method() == 'POST') {
if (!$validator->fails()) {
$category_select = Input::get('product_category');
$category = ProductTypes::find($category_select);
if ($category) {
/** @var Products $product */
$product = new Products();
$product->uid = Uuid::generate()->string;
$product->name = Input::get('product_name');
$product->short_description = Input::get('short_description');
$product->description = Input::get('product_description');
$product->price_in_cents = Input::get('price') * 100;
$product->quantity = Input::get('quantity');
$product->product_type_id = $category->id;
$product->allow_review = 1;
$product->save();
if ($product->save()) {
if (Input::file('main_product_image')) {
$filename = Input::file('main_product_image')->getClientOriginalName();
$destination = storage_path() . '/app/upload/';
$file_path = Input::file('main_product_image')->move($destination, $filename);
// $diskLocal = Storage::disk('local');
$product_image = new ProductImages();
$product_image->url = $filename;
$product_image->product_id = $product->id;
$product_image->name = $filename;
$product_image->is_primary = 1;
$product_image->save();
}
}
$success_msg[] = 'Product Added!';
} else {
$error_msg[] = 'Whoops! Sorry, product category not found';
}
} else {
return Redirect::back()->withErrors($validator->messages())->withInput(Input::all());
}
}
return View::make('shop.manage_store', ['product_types' => $product_types, 'success_msg' => $success_msg, 'error_msg' => $error_msg]);
}
示例4: anyAddInvoiceItems
public function anyAddInvoiceItems()
{
$invoice_details = InvoiceDetails::get();
$items = InvoiceItems::all();
if (Request::method() == 'POST') {
$invoice_items = new InvoiceItems();
$invoice_items->invoice_id = Input::get('invoice_id');
$invoice_items->quantity = Input::get('quantity');
$invoice_items->product = Input::get('product');
$invoice_items->price_in_cents = Input::get('price') * 100;
$invoice_items->currency_code = Input::get('currency_code');
$invoice_items->save();
return Redirect::back()->with('success', 'Items Added!');
} else {
return View::make('invoice.invoice_items', ['invoices' => $invoice_details, 'invoice_items' => $items]);
}
}
示例5: exceptionToSlackAttach
/**
* Transform an exception to attachment array for slack post
*
* @param E $e
*
* @return array
*/
protected static function exceptionToSlackAttach(E $e)
{
$fields = [];
$addToField = function ($name, $value, $short = false) use(&$fields) {
if (!empty($value)) {
$fields[] = ["title" => $name, "value" => $value, "short" => $short];
}
};
$addToField("Exception", get_class($e), true);
$addToField("Hash", ExceptionHelper::hash($e), true);
$addToField("Http code", ExceptionHelper::statusCode($e), true);
$addToField("Code", $e->getCode(), true);
$addToField("File", $e->getFile(), true);
$addToField("Line", $e->getLine(), true);
$addToField("Request url", Request::url(), true);
$addToField("Request method", Request::method(), true);
$addToField("Request param", json_encode(Request::all()), true);
return ["color" => "danger", "title" => $e->getMessage(), "fallback" => !empty($e->getMessage()) ? $e->getMessage() : get_class($e), "fields" => $fields, "text" => $e->getTraceAsString()];
}
示例6: update
/**
* Update item.
*
* @return \Modules\Articles\Entities\Article
*/
public function update($id, &$context)
{
$article = $this->findById($id);
if (Request::method() == 'PATCH') {
// restore
if (Request::has('restore') && (int) Request::get('restore')) {
$article->restore();
$context = 'restored';
return $article;
} else {
$data = array_merge($article->toArray(), Request::except($this->publishing_columns));
// exclude missing keys
$domain_data = CoreRequest::only($this->publishing_columns);
// process domain data
$article_data = is_null($article->data) ? [] : $article->data->toArray();
$domain_data = array_merge(Arr::only($article_data, $this->publishing_columns), $domain_data);
}
} else {
$input = Request::except($this->publishing_columns);
$domain_data = Request::only($this->publishing_columns);
// validate
$data = $this->validate($input, $article->id);
// slug is slug
$data['slug'] = Str::slug(Arr::get($data, 'slug') ?: $data['title']);
}
// update
$article->update($data);
//
// update data
//
// create
if (is_null($article->data)) {
(new ArticleDomainDataRepository())->create($article->toArray() + $domain_data);
} else {
$article->data()->update(ArticleDomainDataRepository::validate($domain_data) + ['modified_by' => Request::header('UID', 0)]);
$article->data()->touch();
}
return $article;
}
示例7: anyUpdateStatus
public function anyUpdateStatus($booking_uid, $status)
{
$booking = Bookings::where('uid', '=', $booking_uid)->first();
$error_msg = [];
$tz = new \DateTimeZone('NZ');
$now = new \DateTime(date('Y-m-d H:i:s'));
$now->setTimezone($tz);
$current_date_time = $now->format('Y-m-d H:i:s');
$success = false;
$booking_date = Input::get('booking_date');
$booking_time = Input::get('booking_time');
if (Request::method() == 'GET') {
return view('booking.update_status', ['booking' => $booking, 'success' => $success, 'status' => $status, 'error_msg' => $error_msg]);
} else {
if ($booking) {
if ($status == 'consulted') {
$booking->pending = 0;
$booking->consulted = 1;
$booking->completed = 0;
$booking->cancelled = 0;
$booking->consulted_at = $current_date_time;
$booking->save();
$success = true;
} elseif ($status == 'completed') {
if ($booking_date && $booking_time) {
$booking->pending = 0;
$booking->consulted = 0;
$booking->completed = 1;
$booking->cancelled = 0;
$booking->completed_at = $current_date_time;
$booking->booking_date = date('Y-m-d', strtotime($booking_date));
$booking->booking_time = date('H:i:s', strtotime($booking_time));
$booking->save();
$success = true;
} else {
$error_msg[] = 'Booking date and booking time are required.';
$success = false;
}
} elseif ($status == 'cancelled') {
$booking->pending = 0;
$booking->consulted = 0;
$booking->completed = 0;
$booking->cancelled = 1;
$booking->cancelled_at = $current_date_time;
$booking->save();
$success = true;
} else {
$error_msg[] = 'No status selected';
$success = false;
}
if ($success) {
return Redirect::back()->with('success', $success);
} else {
return view('booking.update_status', ['booking' => $booking, 'success' => $success, 'status' => $status, 'error_msg' => $error_msg]);
}
} else {
return Redirect::back()->with(['success', $success, 'error_msg', $error_msg]);
}
}
}
示例8: validateSignedURL
public function validateSignedURL($actual_url, $signed_url, $substitions)
{
$current_route = Request::route();
$current_route_name = $current_route->getName();
if (isset($substitions[$current_route_name])) {
$substition = $substitions[$current_route_name];
// make sure the host of the signed URL matches the host of the substitution URL
if (isset($substition['host'])) {
$signed_host = $this->getHostFromURL($signed_url);
$allowed_host = $substition['host'];
if ($signed_host != $allowed_host) {
Log::debug("HOST MISMATCH: \$signed_host={$signed_host} \$allowed_host={$allowed_host}");
// no host match - return false
return false;
}
}
// check the route
$substitute_route = new Route($current_route->getMethods(), $substition['route'], []);
$signed_request = \Illuminate\Http\Request::create($signed_url, Request::method());
if ($substitute_route->matches($signed_request)) {
// the allowed substitute route matches the signed request
return true;
}
Log::debug("ROUTE MISMATCH: pathinfo=" . json_encode(Request::getFacadeRoot()->getPathInfo()) . " allowed route={$substition['route']}");
}
// this signed URL was not valid
return false;
}
示例9: getMethod
/**
* Gets the Method of the Request
* @return string|null Possible values are null or GET, POST, DELETE, PUT, etc...
*/
protected function getMethod()
{
$method = Request::method();
if (!empty($method)) {
return $method;
} else {
return null;
}
}
示例10: __construct
public function __construct()
{
$this->result['meta'] = ['url' => Request::url(), 'method' => Request::method()];
}
示例11: getRulesAttribute
public function getRulesAttribute()
{
if ($this->rulesParsed) {
return $this->rules;
//Prevents 'required' and update IDS being added many times
}
if ($this->id) {
//Existing record
foreach ($this->unique as $value) {
//Stops the unique values from ruining everything
$this->rules[$value] = $this->rules[$value] . "," . $this->id;
}
$this->rules = AddRule($this->rules, $this->onUpdateRequired, 'required');
//Need to require things after appending the ID
}
if (Request::method() == "POST" || Request::method() == "GET") {
//Initial create
$this->rules = AddRule($this->rules, $this->onCreateRequired, 'required');
//return $this->rules; //DOn't add on things that aren't actual validation rules
}
$this->rulesParsed = true;
return $this->rules;
}