當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。