Category : request

I’ve extended the IlluminateHttpRequest class and am passing it along to my controller. use IlluminateHttpRequest; class MyRequest extends Request { … } Controller class MyController { // Doesnt work public function something(MyRequest $request) { var_dump($request->session()) } // Does work public function something(IlluminateHttpRequest $request) { var_dump($request->session()) } } So when I’m trying to get session $request->session() ..

Read more

I’am sending parameters from one to another without pasing through route pass them another way for security, but problem last function loses parameter and even dd doesn’t work it returns view only with udefined variable $data. Here is my code in controller: public function show_auth($id) //pass id to test.auth { return view(‘test.auth’,compact(‘id’)); } public function ..

Read more

My situation is using Laravel 7 want to use Shopee API Sending request in Laravel should be like this $res = Http::withHeaders([ ‘Content-Type’ => ‘application/json’, ‘Authorization’ => $secret_key ])->post($api_url, [ "ordersn_list" => [$order_no], "shopid" => $shop_id, "partner_id" => $partner_id, "timestamp" => $timestamp ]); But Shopee API need no space in body part (cannot send as ..

Read more

I have a controller that should give permission to use a resource for one IP. If the IP is an invalid controller should give a customized error "Not correct IP". But when executing the controller, I keep getting the customized error "Not correct IP". When I send $request->ip() I get "::1" I am using localhost ..

Read more

I’m trying to build a login with passport using an access token and a refresh token: class AuthController extends Controller { const REFRESH_TOKEN = ‘refreshToken’; public function login(Request $request) { $request->validate([ ‘username’ => ‘required|email’, ‘password’ => ‘required’, ]); return $this->proxy(‘password’, [ ‘username’ => $request->username, ‘password’ => $request->password, ]); } public function proxy($grantType, array $data = ..

Read more

I’m building an API and trying to give the user the ability to login. At first I was trying to use guzzle: public function login(Request $request) { $http = new GuzzleHttpClient; try { $response = $http->post(config(‘services.passport.login_endpoint’), [ ‘form_params’ => [ ‘grant_type’ => ‘password’, ‘client_id’ => config(‘services.passport.client_id’), ‘client_secret’ => config(‘services.passport.client_secret’), ‘username’ => $request->username, ‘password’ => $request->password, ..

Read more

Im having a trouble to show the errors on my view. Im using request, and also i am validating in the controller. This is the part of the view on the code that has errors. @if ($errors->any()) <div class=”col-md-12″> <label>Errores</label> <div class=”alert alert-danger”> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> </div> ..

Read more