本文整理汇总了PHP中Illuminate\Support\Facades\Input::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::replace方法的具体用法?PHP Input::replace怎么用?PHP Input::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Input
的用法示例。
在下文中一共展示了Input::replace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSortableWithRequestParameters
public function testSortableWithRequestParameters()
{
$usersTable = $this->user->getTable();
Input::replace(['sort' => 'name', 'order' => 'asc']);
$resultArray = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$expected = ['column' => $usersTable . '.name', 'direction' => 'asc'];
$this->assertEquals($expected, head($resultArray));
Input::replace(['sort' => 'name', 'order' => 'desc']);
$resultArray = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$expected = ['column' => $usersTable . '.name', 'direction' => 'desc'];
$this->assertEquals($expected, head($resultArray));
Input::replace(['sort' => 'name', 'order' => '']);
$result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$this->assertNull($result);
Input::replace(['sort' => '', 'order' => 'asc']);
$result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$this->assertNull($result);
Input::replace(['sort' => '', 'order' => '']);
$result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$this->assertNull($result);
Input::replace(['sort' => 'name']);
$result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$this->assertNull($result);
Input::replace(['sort' => '']);
$result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
$this->assertNull($result);
}
示例2: modifyPost
/**
* Ensures the correct URL value is saved to the model
*/
protected function modifyPost()
{
$new_post_data = post();
if (post('Menu')['is_external'] == "1") {
$new_post_data['Menu']['url'] = $new_post_data['Menu']['external_url'];
} else {
$new_post_data['Menu']['url'] = $new_post_data['Menu']['internal_url'];
}
unset($new_post_data['Menu']['internal_url']);
unset($new_post_data['Menu']['external_url']);
Input::replace($new_post_data);
}
示例3: fastRequest
protected function fastRequest($uri, $method, $input = array())
{
$uri = $this->config['prefix'] . $uri;
$method = strtoupper($method);
if ($this->config['local']) {
$oldInput = Input::all();
Input::replace($input);
$request = Request::create($uri, $method, array());
$response = Route::dispatch($request);
$content = $response->getContent();
$code = $response->getStatusCode();
$results = json_decode($content);
Input::replace($oldInput);
} else {
if ($method === 'GET') {
$uri .= '?' . urldecode(http_build_query($input));
}
$client = new Client($this->config['domain']);
$request = $client->createRequest($method, $uri, array(), $method === 'GET' ? array() : $input)->addHeader('Content-Type', 'application/json');
try {
$response = $request->send();
} catch (ClientErrorResponseException $e) {
$response = $e->getResponse();
}
$code = $response->getStatusCode();
$results = $response->json();
}
if (!Str::startsWith((string) $code, "2")) {
throw new ApiException($results, $code);
}
return $results;
}
示例4: testComplex
public function testComplex()
{
$engine = new CollectionEngine(new Collection($this->getRealArray()));
$this->addRealColumns($engine);
$engine->searchColumns('foo', 'bar');
$engine->setAliasMapping();
Input::replace(array('sSearch' => 't'));
$test = json_decode($engine->make()->getContent());
$test = $test->aaData;
$this->assertTrue($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
$this->assertTrue($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
//Test2
$engine = new CollectionEngine(new Collection($this->getRealArray()));
$this->addRealColumns($engine);
$engine->searchColumns('foo', 'bar');
$engine->setAliasMapping();
Input::replace(array('sSearch' => 'plasch'));
$test = json_decode($engine->make()->getContent());
$test = $test->aaData;
$this->assertTrue($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
$this->assertFalse($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
//test3
$engine = new CollectionEngine(new Collection($this->getRealArray()));
$this->addRealColumns($engine);
$engine->searchColumns('foo', 'bar');
$engine->setAliasMapping();
Input::replace(array('sSearch' => 'tay'));
$test = json_decode($engine->make()->getContent());
$test = $test->aaData;
$this->assertFalse($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
$this->assertTrue($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
//test4
$engine = new CollectionEngine(new Collection($this->getRealArray()));
$this->addRealColumns($engine);
$engine->searchColumns('foo', 'bar');
$engine->setAliasMapping();
Input::replace(array('sSearch' => 'O'));
$test = json_decode($engine->make()->getContent());
$test = $test->aaData;
$this->assertFalse($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
$this->assertTrue($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
}
示例5: one
/**
*
* @return mixed
*/
protected function one()
{
$this->id = Input::get('id');
$fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null;
if ($this->action == "add") {
// @todo test
$user = $this->validateAndCreate($fill);
} else {
$user = \Veer\Models\User::find($this->id);
}
if (!is_object($user)) {
return event('veer.message.center', trans('veeradmin.error.model.not.found'));
}
if (!empty($fill)) {
$user->fill($fill);
}
$user->save();
$this->id = $user->id;
$this->user = $user;
$this->goThroughEverything();
if ($this->action == "add") {
app('veer')->skipShow = true;
Input::replace(['id' => $this->id]);
return \Redirect::route('admin.show', ['users', 'id' => $this->id]);
}
}
示例6: syslog
}
}
}
if ($impure) {
// report banned input
//
$userUid = Session::get('user_uid');
syslog(LOG_WARNING, "User {$userUid} attempted to send unsanitary input containing HTML tags or script: " . json_encode($bannedInput));
Input::replace($input);
// return error
//
return Response::make("Can not send unsanitary input containing HTML tags or script.", 400);
} else {
// return sanitized input
//
Input::replace($input);
}
});
App::after(function ($request, $response) {
$response->headers->set('Access-Control-Allow-Origin', Config::get('app.cors_url'));
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', '*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token');
$response->headers->set('Access-Control-Allow-Credentials', 'true');
$response->headers->remove('Cache-Control');
return $response;
});
/**
* Validation of enabled users.
*/
Route::filter('user_enabled_check', function ($route, $request) {
$user_uid = Session::get('user_uid');
示例7: prepareRequest
public static function prepareRequest()
{
$className = \Request::segment(3);
if (isset($className)) {
$object = self::makeModelObject($className);
$inputs = Input::all();
$inputs = self::prepareRequestBasicFields($inputs, $object);
$inputs = self::prepareRequestDateFields($inputs);
$inputs = self::prepareRequestBytesFields($inputs);
$inputs = self::prepareRequestRelations($inputs, $object);
Input::replace($inputs);
}
}
示例8: one
protected function one()
{
$this->id = Input::get('id');
$this->action = Input::get('action');
$this->order = \Veer\Models\Order::find($this->id);
if (!is_object($this->order)) {
$this->order = new \Veer\Models\Order();
}
$fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null;
if ($this->action == "delete") {
$this->delete();
app('veer')->skipShow = true;
return \Redirect::route('admin.show', ['orders']);
}
if ($this->order->status_id != $fill['status_id']) {
$addStatusToHistory = true;
}
if ($this->order->userbook_id != $fill['userbook_id']) {
$this->userbookToOrder($fill['userbook_id'], false);
}
$this->order->fill($fill);
if ($this->action == "add") {
$result = $this->addOrder($fill, Input::get('userbook.0', []), Input::get('attachContent'), ['_skipObjectCreate' => true, '_skipPrepare' => true, '_allowSkipContent' => false]);
if ($result === false) {
return false;
}
$addStatusToHistory = true;
$this->id = $this->order->id;
}
$this->goThroughEverything();
$this->order->save();
$this->id = $this->order->id;
if (isset($addStatusToHistory)) {
$this->status(['status_id' => $this->order->status_id]);
}
if ($this->action == "add" && $this->order->userdiscount_id > 0 && !empty($this->discount)) {
app('veershop')->changeUserDiscountStatus($this->discount);
}
if (Input::has('sendMessageToUser')) {
(new \Veer\Commands\CommunicationSendCommand(Input::get('communication')))->handle();
event('veer.message.center', trans('veeradmin.user.page.sendmessage'));
}
if ($this->action == "add") {
$this->sendEmail();
app('veer')->skipShow = true;
Input::replace(['id' => $this->order->id]);
return \Redirect::route('admin.show', ['orders', 'id' => $this->order->id]);
}
}
示例9: one
/**
* @return mixed
*/
protected function one()
{
$this->id = Input::get('category');
$category = \Veer\Models\Category::find($this->id);
if (!is_object($category)) {
event('veer.message.center', trans('veeradmin.error.model.not.found'));
return \Redirect::route('admin.show', ['categories']);
}
$this->entity = $category;
$this->goThroughEverything();
if ($this->action == 'deleteCurrent') {
Input::replace(['category' => null]);
app('veer')->skipShow = true;
event('veer.message.center', trans('veeradmin.category.delete'));
return \Redirect::route('admin.show', ['categories']);
}
}
示例10: one
/**
* @helper Model create|find
* @return mixed
*/
protected function one()
{
$this->id = Input::get('id');
$fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null;
if ($this->action == 'add' || $this->action == 'saveAs') {
if ($this->type == 'page') {
$fill['hidden'] = true;
} elseif ($this->type == 'product') {
$fill['status'] = 'hide';
}
$entity = $this->create($fill);
} else {
$className = $this->className;
$entity = $className::find($this->id);
}
if (!is_object($entity)) {
event('veer.message.center', trans('veeradmin.error.model.not.found'));
return \Redirect::route('admin.show', [str_plural($this->type)]);
}
$this->id = $entity->id;
$this->entity = $entity;
$this->goThroughEverything($fill);
if ($this->action == 'add' || $this->action == 'saveAs') {
app('veer')->skipShow = true;
Input::replace(['id' => $this->id]);
return \Redirect::route('admin.show', [str_plural($this->type), 'id' => $this->id]);
}
}
示例11: addSlugToInput
protected function addSlugToInput()
{
$data = Input::all();
$data['slug'] = Str::slug(Input::get('name'));
Input::replace($data);
}