Skip to content
Advertisement

Tag: laravel

Get request for the policies in controller constructor

I’m setting up policies for my laravel application, and I’m stuck with a problem. I have to put the policy in the constructor of my controller this way: Problem is, for the store action, I have to check one of the params sent in the request to check if the user is allowed to post on the related parent. According

multiple recipients email sent with htmlspecialchars() expects parameter error

I have a form, in which when I fill and submit, it’s sent email to multiple recipient, when I do that I get this error htmlspecialchars() expects parameter 1 to be string, array given (View: C:wamp64wwwstarresourcesviewsemailsemail_invite_template.blade.php below is my code: The Form SendEmail Controller Email Template (email_invite_template.php) Thanks Answer You can’t just pass forward $data on every iteration. You need

REST convention when transforming data

I use Laravel as a REST API service for uploading and storing books. The book service follows the standard REST convention: GET: /api/books and /api/books/<book_id> for retrieving book(s) PUT: /api/books/<book_id> for updating a book POST: /api/books for adding a new book DELETE: /api/books/<book_id> for deleting a book So far so good. Now I need another endpoint which should be used

Laravel create custom exception with parameters & return as JSON

I want to throw a custom exception if the variable is null and return it as JSON. I’ve tried like this: Controller Custom Exception But when I am trying to test it using postman, the return I got is not the same as I wrote in NullException. It becomes like this: Answer In your case you are returning the exception

Laravel: pass field to resolveRouteBinding from route definition

I have a seemingly stupid question here but I can’t find how one is supposed to define explicit model binding resolution logic using resolveRouteBinding method on a Model. I managed to write down its logic which is based on the value of the field parameter but I can’t seem to work out how to pass a value to this parameter

How to make unlimited category json listing?

I want to get unlimited json loop with category parent_id but I couldn’t find how to do that. Do while I searched but. I couldn’t find the source. How can I do the foreach loop do while? Can you guide me on this? Json result; Laravel code; Answer A recursive map operation seems perfect for this situation. If you don’t

Advertisement