本文整理汇总了PHP中request函数的典型用法代码示例。如果您正苦于以下问题:PHP request函数的具体用法?PHP request怎么用?PHP request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
if (request()->ajax()) {
return $this->getUpcomingBooks(Auth::user()->id);
}
return view('books.upcoming');
}
示例2: task_list
function task_list($admin_id)
{
$url = $prefix . '/admin/' . $admin_id . '/list';
$result = request($url);
if (!empty($result)) {
}
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store()
{
$this->validate(request(), ['note' => ['required', 'max:200']]);
$data = request()->all();
Note::create($data);
return redirect()->to('notes');
}
示例4: __construct
public function __construct($companyId = null)
{
parent::__construct();
if ($companyId !== null) {
$this->company = Company::instance()->find($companyId);
} else {
$this->company = new Company();
}
$this->exists = $this->company->exists();
if ($this->exists) {
$this->prependSiteTitle(lang('Companies.EditCompany', $this->company->name));
} else {
$this->prependSiteTitle(lang('Companies.AddCompany'));
}
if ($this->isPostBack()) {
$this->validate(['name' => [new NotNullOrEmpty()]]);
if (!$this->hasErrors()) {
$this->company->save(['name' => input()->get('name'), 'ip' => request()->getIp()]);
if ($this->exists) {
$this->setMessage(lang('Companies.CompanyUpdated'), 'success');
} else {
$this->setMessage(lang('Companies.CompanySaved'), 'success');
}
// Refresh
response()->refresh();
}
}
}
示例5: testConvenienceFunction
public function testConvenienceFunction()
{
$x = request();
$this->assertEquals(request(), $x);
$x = request('method');
$this->assertEquals('GET', $x);
}
示例6: run
public function run($id = false, $model = false, $forceDelete = false)
{
$modelName = $this->model && is_string($this->model) ? $this->model : (request()->getParam('model') ? request()->getParam('model') : $this->controller->model);
if ($id) {
//delete one model
$result = $this->controller->loadModel($modelName, $id)->delete();
if (!request()->isAjaxRequest && $result) {
$this->controller->redirect(user()->gridIndex);
}
Common::jsonSuccess(true);
} else {
$items = Common::getChecked('items');
if ($items) {
if (!$forceDelete) {
foreach ($items as $id) {
$this->controller->loadModel($modelName, $id)->delete();
}
} else {
$criteria = new SDbCriteria();
$criteria->compare('id', $items);
CActiveRecord::model($modelName)->deleteAll($criteria);
}
Common::jsonSuccess(true);
}
}
Common::jsonError("Ошибка");
}
示例7: index
public function index()
{
$token = config('global.token');
$role = \Input::get('role');
if (!empty($token)) {
$cacheTag = ['managers', 'auth'];
$cacheKey = $token;
$data = Cache::tags($cacheTag)->remember($cacheKey, 60 * 48, function () use($token) {
$_manager = Managers::where('token', $token)->where('ip', request()->ip());
if ($_manager->count() > 0) {
return $_manager->first()->toArray();
} else {
return false;
}
});
if ($data) {
if (!empty($role)) {
$roles = !is_array($role) ? [$role] : $role;
if (!in_array($data['role'], $roles)) {
return new \Exception('Você não tem permissão para realizar esta ação.');
}
}
return ['name' => $data['name'], 'email' => $data['email'], 'role' => $data['role'], 'avatar' => $data['avatar']];
} else {
Cache::tags($cacheTag)->forget($cacheKey);
return new \Exception('Token de acesso inválido. Faça login novamente');
}
} else {
return new \Exception('Chave de acesso não encontrada. Você precisa fazer login');
}
}
示例8: actionCreate
public function actionCreate()
{
if (request()->getIsPostRequest()) {
$content = trim($_POST['kwcontent']);
if ($content) {
$keywords = explode("\n", $content);
foreach ((array) $keywords as $kw) {
$kwArray = explode(',', $kw);
$kwArray = array_unique($kwArray);
$model = new FilterKeyword();
$model->keyword = trim($kwArray[0]);
$model->replace = trim($kwArray[1]);
try {
if (!$model->save()) {
$error['keyword'] = $kw;
$error['message'] = implode('; ', $model->getErrors('keyword')) . implode('; ', $model->getErrors('replace'));
$errors[] = $error;
}
} catch (Exception $e) {
$error['keyword'] = $kw;
$error['message'] = $e->getMessage();
$errors[] = $kw;
}
unset($model);
}
FilterKeyword::updateCacheFile();
}
}
$this->adminTitle = t('create_filter_keyword', 'admin');
$this->render('create', array('errors' => $errors));
}
示例9: __construct
public function __construct($esxman, $database, $username = '', $error = null)
{
$this->esxman = $esxman;
$this->database = $database;
$this->username = $username;
$this->html = array('footer' => ' ', 'menu' => ' ', 'tree' => ' ', 'user' => ' ', 'content' => ' ');
$this->commands = array();
$this->title = _('Login');
if (request('form_name') == 'login') {
if ($this->database->authenticate_user(request('username'), request('password'))) {
session_destroy();
session_start();
$_SESSION['username'] = request('username');
$_SESSION['key'] = md5($_SESSION['username'] . getenv('REMOTE_ADDR') . getenv('X-FORWARDED-FOR'));
debug('User ' . request('username') . ' logging in!');
$this->commands[] = "\$('#dialog').html('" . _('Populating inventory...') . "');";
$this->commands[] = js_command('get', 'action=populate_inventory');
return;
}
$error = _('Authentication failed');
}
$tpl = new Template('dialog_login.html');
if ($error) {
$tpl->setVar('error', $error);
$tpl->parse('error_message');
}
$this->commands[] = js_command('display_dialog', _('Login'), $tpl->get(), _('Login'));
}
示例10: play
/**
* Play/stream a song.
*
* @link https://github.com/phanan/koel/wiki#streaming-music
*
* @param Song $song The song to stream.
* @param null|bool $transcode Whether to force transcoding the song.
* If this is omitted, by default Koel will transcode FLAC.
* @param null|int $bitRate The target bit rate to transcode, defaults to OUTPUT_BIT_RATE.
* Only taken into account if $transcode is truthy.
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function play(Song $song, $transcode = null, $bitRate = null)
{
if ($song->s3_params) {
return (new S3Streamer($song))->stream();
}
// If `transcode` parameter isn't passed, the default is to only transcode FLAC.
if ($transcode === null && ends_with(mime_content_type($song->path), 'flac')) {
$transcode = true;
}
$streamer = null;
if ($transcode) {
$streamer = new TranscodingStreamer($song, $bitRate ?: config('koel.streaming.bitrate'), request()->input('time', 0));
} else {
switch (config('koel.streaming.method')) {
case 'x-sendfile':
$streamer = new XSendFileStreamer($song);
break;
case 'x-accel-redirect':
$streamer = new XAccelRedirectStreamer($song);
break;
default:
$streamer = new PHPStreamer($song);
break;
}
}
$streamer->stream();
}
示例11: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(Locale $locale)
{
//only for next request:: ->flash
//session()->flash('active_language_tab',$request->get('active_language_tab'));
// $locales = new Locale(); §
$locales = $locale->getEnabled();
$sitemapRules = ['parent_id' => 'required', 'online' => 'required', 'template_id' => 'required'];
$translationRules = array();
foreach ($locales as $key => $locale) {
$translationRules['translations.' . $locale->languageCode . '.name'] = 'required';
//homepage geen slug , patch is update
if (request()->get('parent_id') != 0 && request()->get('_method') == 'PATCH') {
$translationRules['translations.' . $locale->languageCode . '.slug'] = 'required';
//dc('wel verplicht');
} else {
//dc('niet verplicht');
}
switch ($this->input('post_type')) {
case 'homepage':
//$translationRules['translations.'.$locale->identifier.'.news.author'] = 'required|integer';
//uit
//$translationRules['translations.'.$locale->languageCode.'.homepage.content'] = 'required';
break;
case 'defaultpage-uit':
$translationRules['translations.' . $locale->languageCode . '.defaultpage.content'] = 'required';
break;
default:
}
}
return array_merge($sitemapRules, $translationRules);
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$direction = request()->get('direction');
$orderby = request()->get('orderby');
$posts = $this->postRepo->getPaginatedAndOrdered();
return view('admin::posts.index', compact('posts', 'direction', 'orderby'));
}
示例13: index
/**
* Display a listing of the resource.
*
* @param \App\Models\Article $article
* @return \Illuminate\Http\Response
*/
public function index($article)
{
if (request()->ajax()) {
return response()->json($article->comments);
}
return response('');
}
示例14: deleteVolunteers
public function deleteVolunteers($id)
{
can('event.volunteer');
$this->volunteer_repo->delete(request()->record_id);
flash('volunteer deleted successfully', 'success');
return redirect("/event/volunteers/{$id}");
}
示例15: getRequestInfo
protected function getRequestInfo()
{
if (empty($_SERVER['REQUEST_METHOD']) || !$this->debug) {
return '';
}
$request = request();
try {
$url = !empty($_SERVER['REQUEST_URI']) ? $request->url() : 'Probably console command';
} catch (\UnexpectedValueException $exc) {
$url = 'Error: ' . $exc->getMessage();
}
$title = 'Request Information';
$content = <<<EOF
<div class="request-info">
<hr>
<h2 style="margin: 20px 0 20px 0; text-align: center; font-weight: bold; font-size: 18px;">
<b>{$title}</b><br>
</h2>
<h2 style="font-size: 18px;">({$request->getRealMethod()} -> {$request->getMethod()}) {$url}</h2>
<br>
<div style="font-size: 14px !important">
EOF;
foreach ($this->getAdditionalData() as $label => $data) {
$content .= '<h2 style="margin: 20px 0 20px 0; font-weight: bold; font-size: 18px;">' . $label . '</h2>';
$json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
$content .= <<<EOF
<pre style="border: 1px solid {$this->colors['json_block_border']}; background: {$this->colors['json_block_bg']};
padding: 10px; font-size: 14px !important; word-break: break-all; white-space: pre-wrap;">{$json}</pre>
EOF;
}
return $this->cleanPasswords($content) . '</div></div>';
}