当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::create方法代码示例

本文整理汇总了PHP中Illuminate\Http\Request::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::create方法的具体用法?PHP Request::create怎么用?PHP Request::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Http\Request的用法示例。


在下文中一共展示了Request::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createRequest

 protected function createRequest($method = 'GET')
 {
     $request = LaravelRequest::createFromBase(LaravelRequest::create('/', 'GET'));
     if ($method !== null) {
         $request->headers->set('Access-Control-Request-Method', $method);
     }
     return new Request($request);
 }
开发者ID:trunda,项目名称:php-cors,代码行数:8,代码来源:MethodMatcherTest.php

示例2: createRequest

 protected function createRequest($origin = null)
 {
     $request = LaravelRequest::createFromBase(LaravelRequest::create('/', 'GET'));
     if ($origin !== null) {
         $request->headers->set('Origin', $origin);
     }
     return new Request($request);
 }
开发者ID:trunda,项目名称:php-cors,代码行数:8,代码来源:OriginMatcherTest.php

示例3: call

 /**
  * @param $uri
  * @param $method
  * @param array $parameters
  * @param bool $collection
  *
  * @return mixed|string
  */
 public function call($uri, $method, $parameters = [], $collection = true)
 {
     try {
         $origin_input = $this->request->input();
         $request = $this->request->create($uri, $method, $parameters);
         $this->request->replace($request->input());
         $dispatch = $this->router->dispatch($request);
         $this->request->replace($origin_input);
         return $this->getResponse($dispatch, $dispatch->getContent(), $collection);
     } catch (NotFoundHttpException $e) {
         throw new NotFoundHttpException('Request Not Found.');
     }
 }
开发者ID:killtw,项目名称:laravel-api,代码行数:21,代码来源:Api.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     try {
         $inputs = array('des_name', 'des_coors', 'des_instruction', 'related_photos');
         $obj = array('message' => 'succeeded');
         foreach ($inputs as $field) {
             $obj[$field] = $request->input($field, '');
         }
         // TODO: cuối cùng vẫn phải chạy Raw SQL -_-
         $destination = DB::table('Destination')->insertGetId(array('des_name' => $obj['des_name'], 'des_instruction' => $obj['des_instruction'], 'coordinate' => DB::raw("GeomFromText(\"POINT(" . $obj['des_coors']['latitude'] . " " . $obj['des_coors']['longitude'] . ")\")")));
         // upload selected images too
         $images_uploaded = array();
         $relPhotos = $obj['related_photos'];
         if ($relPhotos) {
             foreach ($relPhotos as $photo) {
                 if ($photo['selected']) {
                     $rq = Request::create("/admin/destination/{$destination}/photo", "POST", [], [], [], [], array('photo_url' => $photo['url'], 'photo_like' => rand(0, 100)));
                     array_push($images_uploaded, Route::dispatch($rq)->getContent());
                 }
             }
         }
         return response()->json(array('addedObject' => Destination::find($destination), 'addedPhotos' => $images_uploaded));
     } catch (\Exception $e) {
         return response()->json($e);
     }
 }
开发者ID:hungphongbk,项目名称:ulibi,代码行数:32,代码来源:DestinationController.php

示例5: setUp

 /**
  * Setup test environment.
  */
 public function setUp()
 {
     $this->app = new Application();
     $this->app['request'] = Request::create('/');
     $this->app['html'] = new HTML($this->app);
     $this->form = new Form($this->app);
 }
开发者ID:rcrowe,项目名称:form,代码行数:10,代码来源:FormTest.php

示例6: setUp

 /**
  * Setup the test environment.
  */
 public function setUp()
 {
     $this->urlGenerator = new UrlGenerator(new RouteCollection(), Request::create('/foo', 'GET'));
     $this->htmlBuilder = new HtmlBuilder($this->urlGenerator);
     $this->siteKey = 'my-site-key';
     $this->recaptchaBuilder = new RecaptchaBuilder($this->siteKey, $this->htmlBuilder);
 }
开发者ID:noylecorp,项目名称:laravel-recaptcha,代码行数:10,代码来源:RecaptchaBuilderTest.php

示例7: invoke

 /**
  * Call internal URI with parameters.
  *
  * @param  string $uri
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function invoke($uri, $method, $parameters = array())
 {
     // Request URI.
     $uri = '/' . ltrim($uri, '/');
     // Parameters for GET, POST
     $parameters = $parameters ? current($parameters) : array();
     try {
         // store the original request data and route
         $originalInput = $this->request->input();
         $originalRoute = $this->router->getCurrentRoute();
         // create a new request to the API resource
         $request = $this->request->create($uri, strtoupper($method), $parameters);
         // replace the request input...
         $this->request->replace($request->input());
         $dispatch = $this->router->dispatch($request);
         if (method_exists($dispatch, 'getOriginalContent')) {
             $response = $dispatch->getOriginalContent();
         } else {
             $response = $dispatch->getContent();
         }
         // Decode json content.
         if ($dispatch->headers->get('content-type') == 'application/json') {
             if (function_exists('json_decode') and is_string($response)) {
                 $response = json_decode($response, true);
             }
         }
         // replace the request input and route back to the original state
         $this->request->replace($originalInput);
         $this->router->setCurrentRoute($originalRoute);
         return $response;
     } catch (NotFoundHttpException $e) {
     }
 }
开发者ID:ddedic,项目名称:nexsell,代码行数:41,代码来源:Api.php

示例8: testShouldUpdate

 public function testShouldUpdate()
 {
     // create user and logged in (the user who will perform the action)
     $user = User::create(array('first_name' => 'darryl', 'email' => 'darryl@gmail.com', 'password' => 'pass$darryl', 'permissions' => array('superuser' => 1)));
     $this->application['auth']->loginUsingId($user->id);
     // create the group that we will be updating
     $blogger = Group::create(array('name' => 'blogger', 'permissions' => array('blog.list' => 1, 'blog.create' => 1, 'blog.edit' => 1, 'blog.delete' => -1)));
     // dummy request
     // we will update the blogger group that it will not be able to create a blog now
     $request = Request::create('', 'POST', array('id' => $blogger->id, 'name' => 'blogger-renamed', 'permissions' => array('blog.list' => 1, 'blog.create' => -1, 'blog.edit' => 1, 'blog.delete' => -1)));
     // begin
     $result = $this->commandDispatcher->dispatchFromArray('Darryldecode\\Backend\\Components\\User\\Commands\\UpdateGroupCommand', array('id' => $request->get('id', null), 'name' => $request->get('name', null), 'permissions' => $request->get('permissions', array())));
     $this->assertTrue($result->isSuccessful(), 'Transaction should be successful.');
     $this->assertEquals(200, $result->getStatusCode(), 'Status code should be 200.');
     $this->assertEquals('Group successfully updated.', $result->getMessage());
     // now prove it has been updated
     $updatedGroup = Group::find($result->getData()->id);
     //$this->assertEquals('blogger-renamed', $updatedGroup->name);
     $this->assertArrayHasKey('blog.list', $updatedGroup->getPermissionsAttribute(), 'Group permissions should have key blog.list');
     $this->assertArrayHasKey('blog.create', $updatedGroup->getPermissionsAttribute(), 'Group permissions should have key blog.create');
     $this->assertArrayHasKey('blog.edit', $updatedGroup->getPermissionsAttribute(), 'Group permissions should have key blog.edit');
     $this->assertArrayHasKey('blog.delete', $updatedGroup->getPermissionsAttribute(), 'Group permissions should have key blog.delete');
     $this->assertEquals(1, $updatedGroup->getPermissionsAttribute()['blog.list'], 'Permission blog.list should be allow');
     $this->assertEquals(-1, $updatedGroup->getPermissionsAttribute()['blog.create'], 'Permission blog.create should be deny');
     $this->assertEquals(1, $updatedGroup->getPermissionsAttribute()['blog.edit'], 'Permission blog.edit should be allow');
     $this->assertEquals(-1, $updatedGroup->getPermissionsAttribute()['blog.delete'], 'Permission blog.delete should be deny');
 }
开发者ID:darryldecode,项目名称:laravelbackend,代码行数:27,代码来源:UpdateGroupCommandTest.php

示例9: index

 public function index()
 {
     $dataAccess = new ClientMng();
     //$clients = $dataAccess->getClientsFromUsers();
     $request = Request::create('/api/clients', 'GET');
     $response = Route::dispatch($request);
     $obj = json_decode($response->content(), true);
     $clients = $obj["data"];
     if (\Request::has('search')) {
         $query = \Request::get('search');
         $results = $dataAccess->search($query);
         if (count($results) < 1) {
             $results = $dataAccess->searchRaw($query);
         }
         return \View::make('clientlist')->with('clients', $results);
     }
     //$obj2 = $obj["data"];
     //        foreach($obj as $i)
     //        {
     //            //echo $i[1]["firstName"];
     //            //echo print_r($i);
     //            array_push($obj2, $i);
     //        }
     //echo $response;
     //echo print_r($obj2);
     //echo $clients[0]["id"];
     //echo $response->content();
     //echo print_r($obj2);
     return \View::make('clientlist')->with('clients', $clients);
 }
开发者ID:joshsimard,项目名称:COMP4350-Project,代码行数:30,代码来源:ClientListController.php

示例10: testValidCredentialsReturnsUser

 public function testValidCredentialsReturnsUser()
 {
     $request = Request::create('GET', '/', [], [], [], ['HTTP_AUTHORIZATION' => 'Basic 12345']);
     $this->auth->shouldReceive('onceBasic')->once()->with('email', $request)->andReturn(null);
     $this->auth->shouldReceive('user')->once()->andReturn('foo');
     $this->assertEquals('foo', $this->provider->authenticate($request, new Route(['GET'], '/', [])));
 }
开发者ID:jacobDaeHyung,项目名称:api,代码行数:7,代码来源:BasicProviderTest.php

示例11: it_should_return_false_if_no_token_in_request

 /** @test */
 public function it_should_return_false_if_no_token_in_request()
 {
     $request = Request::create('foo', 'GET', ['foo' => 'bar']);
     $parser = new TokenParser($request);
     $this->assertFalse($parser->parseToken());
     $this->assertFalse($parser->hasToken());
 }
开发者ID:levieraf,项目名称:jwt-auth,代码行数:8,代码来源:TokenParserTest.php

示例12: confirmation

 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function confirmation(Request $request)
 {
     $ticketIds = array_filter(array_unique(preg_split('/(\\s|,)/', $request['tickets'])), 'is_numeric');
     if (empty($ticketIds)) {
         return redirect('/');
     }
     $projectId = $request['project'];
     // no leading zeros
     $ticketIds = array_map(function ($value) {
         return ltrim($value, '0 ');
     }, $ticketIds);
     /** @var \Illuminate\Database\Eloquent\Collection $doubledTickets */
     $doubledTickets = Ticket::whereIn('id', $ticketIds)->where('project_id', $projectId)->get();
     // in case there are no doubled tickets we will directly print all tickets
     if ($doubledTickets->isEmpty()) {
         /** @var Request $request */
         $request = Request::create('/printAction', 'POST', ['tickets' => implode(',', $this->buildTicketNames($ticketIds, $projectId))]);
         return $this->printAction($request);
     } else {
         // to reprint doubled Tickets we need a confirmation
         $freshTicketIds = array_diff($ticketIds, $doubledTickets->lists('id')->toArray());
         $freshTicketIds = $this->buildTicketNames($freshTicketIds, $projectId);
         return view('pages.confirmation')->with('doubledTickets', $doubledTickets)->with('freshTicketIds', implode(',', $freshTicketIds))->with('project', $projectId);
     }
 }
开发者ID:ChristophJaecksF4H,项目名称:tico_test,代码行数:29,代码来源:IndexController.php

示例13: testGettingUserWhenNotAuthenticatedAttemptsToAuthenticateAndReturnsNull

 public function testGettingUserWhenNotAuthenticatedAttemptsToAuthenticateAndReturnsNull()
 {
     $this->router->setCurrentRoute($route = new Route(['GET'], 'foo', ['protected' => true]));
     $this->router->setCurrentRequest($request = Request::create('foo', 'GET'));
     $auth = new Authenticator($this->router, $this->container, ['provider' => Mockery::mock('Dingo\\Api\\Auth\\Provider')]);
     $this->assertNull($auth->user());
 }
开发者ID:jacobDaeHyung,项目名称:api,代码行数:7,代码来源:AuthenticatorTest.php

示例14: setUp

 /**
  * Setup the test environment.
  */
 public function setUp()
 {
     $this->urlGenerator = new UrlGenerator(new RouteCollection(), Request::create('/foo', 'GET'));
     $this->htmlBuilder = new HtmlBuilder($this->urlGenerator);
     $this->formBuilder = new FoundationFiveFormBuilder($this->htmlBuilder, $this->urlGenerator, 'abc', new ViewErrorBag());
     $this->attributes = ['id' => 'test-input'];
 }
开发者ID:timothyvictor,项目名称:laravel5-foundation,代码行数:10,代码来源:FormBuilderTest.php

示例15: testValidationPassesWithDifferentProtocols

 public function testValidationPassesWithDifferentProtocols()
 {
     $validator = new Domain('ftp://foo.bar');
     $this->assertTrue($validator->validate(Request::create('http://foo.bar', 'GET')), 'Validation failed when it should have passed with a valid domain.');
     $validator = new Domain('https://foo.bar');
     $this->assertTrue($validator->validate(Request::create('http://foo.bar', 'GET')), 'Validation failed when it should have passed with a valid domain.');
 }
开发者ID:leloulight,项目名称:laravel_latest,代码行数:7,代码来源:DomainTest.php


注:本文中的Illuminate\Http\Request::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。