Questions tagged [laravel-response]
53 questions
0
votes
1 answer
Laravel Restful Api: Call to a member function toBase() on null
I'm using Laravel 5.8 and I wanted to retrieve some data from an Api route:
Route::prefix('v1')->namespace('Api\v1')->group(function(){
Route::get('/articles','ArticleController@index');;
});
Then I made a Resource Collection and a Controller…

japose7523
- 29
- 2
- 15
0
votes
0 answers
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 =…

w3_
- 64
- 1
- 1
- 14
0
votes
1 answer
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()
…

Gaurav
- 149
- 12
0
votes
1 answer
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?
So idon't know how to insert…

CodingStudent
- 53
- 1
- 1
- 9
0
votes
1 answer
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…

Mohsen
- 260
- 3
- 14
0
votes
0 answers
How can I introduce pagination in meta with laravel responder?
I use the following code with Laravel Responder:
return responder()->success(Service::paginate(5), ServiceTransformer::class)->respond();
Laravel Responder is a package for building API responses.
And I get this response:
"status": 200,
…

Mindru Ion
- 373
- 5
- 19
0
votes
3 answers
Passing Company Data to All controller in Laravel 6.x
I am building an app where each company have multiple users. And all users can upload documents/images/xls etc. I want to keep all company data in company separate folder. To complete this I am checking the company detail for every user and then…

Govind M
- 51
- 1
0
votes
1 answer
Laravel 4.2 Response::json converts some strings to integer 0
I'm experiencing an issue with Laravel 4.2 using Response::json
The data returned after querying my database is correct, but when I return it using:
return Response::json($inventory);
some values get converted from their original string value to…

Alain Eid
- 11
- 1
0
votes
1 answer
add status and message keys to the resource json response in laravel
I am using a resource in laravel 5.5 from which I am returning the collection in my controller but I am unable to customize it's output json. I want to add status and message key to it's json output. I have tried to modify the toArray method but…

Uzair
- 186
- 1
- 11
0
votes
1 answer
Error on adding macro for response helper chained with json method in Laravel 5
I'm working on a Laravel 5 Application that only uses API routes. I created a macro to extend the add cookie method of the response helper. But I encountered an error that my macro doesn't exist.
We are using this for returning response:
return…

Letum Falx
- 3
- 2
0
votes
3 answers
Laravel Response method not allowed
Im using this code from the current Laravel documentation
return redirect()->action(
'UserController@profile', ['id' => 1]
);
And changed it to my own controller like this:
return redirect()->action('ProjectController@showProject',['id'=> 2]);…

Armando van Oeffelen
- 111
- 1
- 12
0
votes
1 answer
Laravel JsonResource: array_merge_recursive(): Argument #2 is not an array
I have a JsonResource of Post that should return a single post. But after joining some other data I get this error: array_merge_recursive(): Argument #2 is not an array.
This does not work:
/**
* Display the specified resource.
*
* @param int …

Matt
- 136
- 2
- 17
0
votes
1 answer
Laravel Resource
I have multiple resources and mostly resource content few fields that are same for all other resource and it's very difficult to modify all the resource in case I need to update/add key/value in the resource.
Is there any way that I can create one…

Prafful Panwar
- 439
- 7
- 19
0
votes
2 answers
Laravel custom form requests not validating
I'm have created a custom form request in my laravel 5.6 something like this:

Nitish Kumar
- 6,054
- 21
- 82
- 148
0
votes
1 answer
Laravel return old input of checkbox array
Edit: my $id contains an array
@php($ids = array('Fruit','Vegetables')
I just want to display the old input of my checkbox and textarea when the page returns with errors based on my validations.
Here is the form elements. I tried using the…

jerome
- 695
- 6
- 20