Questions tagged laravel-response

Explore the latest questions and answers asked by our top developers.

Laravel redirect with errormessagebag not returning the actual message

I started a new laravel 8 project and installed the laravel breeze auth starter kit. After that i made an api endpoint and i want to validate the post request going to that endpoint so i wrote some code: $validation = Validator::make($request->all(), [ ‘project_name’ => ‘required’, ‘project_location’ => ‘required’, ‘project_tasks’ => ‘required’, ]); if ($validation->fails()) […]

Using groupBy with resource collection laravel

I am working on api, and using resource to send data. I want to send collection which is grouped by status. So far I have done the following: public function data(){ $collection = ModelNameResource::collection( ModelName::query() ->latest() ->get() ); $data = $collection->groupBy(‘status’); return $data; } Although I have got what I want but want to know […]

How to set isBase64Encoded: True in laravel response

I’m building an application on Laravel 8 and hosting the app on AWS lambda. I want to compress the response with gzip to HTTP request. I had interaction with AWS support and they asked me to add headers with ‘Content-Encoding’ => ‘gzip’, and also add isBase64Encoded to true. To achieve this I tried finding out […]

By Rubal Gulati
Categorised as laravel, laravel-response, php Tagged , ,

How to intercept all responses and change the values of specific keys in Lavavel?

Is there a way, something with a middleware, that can intercept all responses and change the response value if a certain key is found, "before", being delivered, to the "requester", be it the controller, event, any other resource. I need, somehow, every time there is an response and within that response there must be a […]

Laravel insert data to multiple relational tables with a single form

I’m working on Laravel project and i would like to know: how to insert data to my multiple related tables ? How can we insert author id in the author_type_id field of the Author table? How to store author_id in post? my models //Post model class Post extends Model { // protected $fillable = [ […]

Laravel rest api, get the full link of the images associated with the data in database stored in uploads/posts

I am working on the Laravel project project and came across a problem. I would like my function on my ApiController.php to bring me the full links of the images from the POST table, store in uploads / posts. so i tried this method, how can i get this result? //ApiController <?php namespace AppHttpControllers; use […]

Sending flash message via Response Function in Laravel 7

I have a question. I created a middleware to check if the user has an image. Otherwise he goes to the image-upload page and he has to upload an image. Unfortunately in my middleware Redirect Function does not work (I don’t know why!) instead I have to use Response Function. How can I send a […]

By Mohsen
Categorised as laravel, laravel-7, laravel-response

Laravel redirect()->send() does not stop app completely

I might get this entirely wrong, but I was under the impression that redirect()->send() would force the app to stop and redirect the user. As it turns out, it kind of does that, but not entirely. Let’s assume we have the following function. function validate() { $validator = … // a working implementation if ($validator->fails()) […]

By ju5t
Categorised as laravel, laravel-5, laravel-5.8, laravel-response, php

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us