I’m trying to implement validation in my api like this: RideUpdateRequest: So how could I give a error message back in json (if the request validation fails)? Right now in postman I receive nothing back? –EDIT– response: Could I get something like this?: Answer If you take a look at the Form…
Tag: laravel
How to set laravel 5.3 logout redirect path?
Is there no elegant solution to redirect to a specific page after logging out in Laravel 5.3? The function being called is from the trait AuthenticatesUsers: This is a default function from the core of laravel. So I have to override the whole function I cannot edit the core. But isn’t there a more simpl…
Whitespace not caught by Laravel validation
I’m trying to validate a password input field, and spaces are not getting caught by the validator. The password field should be a minimum of 6 characters, and the regex should allow spaces within a password, but not at the beginning or end (I’ve confirmed that this works outside of the validator).…
laravel 5.2 How to get route parameter in blade?
this is my url http://project.dev/blogs/image-with-article so, here I need the parameter image-with-article in my blade to display which is a parameter named slug here is in my routes file I need the slug paramter in blade. Answer I’m not sure what you mean. If you’re trying to construct the route…
Laravel – Eloquent: get posts from user with users post table
I searched a lot but could not find any answer about it, so I hope you could help me! I have three tables: posts, users and post_users. Post_users contains two columns: user_id and post_id. I need to get all posts by an user with Eloquent. Any ideas? Answer Model User: Model Post: Try:
Laravel Eloquent – get last insert of related model
I have a relationship between two models: Terminal and terminalRent. A Terminal can have many terminalRents. I want to get the last Rent for a specific Terminal. When using where() it will reflect those on the Modal hoewever I want to get the last record for terminalRent in relation to the specific terminal. …
Laravel – custom .env file
Laravel assumes that .env file should describe environment, and it should not be committed to your repo. What if I want to keep both .env files for dev and production (say .env-production and .env-…
Run only one unit test from a test suite in laravel
Using phpunit command Laravel will run all unit tests in our project. How to run one or specific Unit Tests in Laravel 5.1? I just want to run testFindToken from my test suite. Answer Use this command to run a specific test from your test suite. If you want to be more specific about your file then pass the fi…
Laravel str_slug not working for unicode bangla
I am working in a laravel project. I have slugged url. Its working fine for English language. But while I use Bangla it returns empty. Please help me to solve the issue. Answer str_slug or facade version Str::slug doesn’t work with non-ascii string. You can instead use this approach
Laravel Middleware / Route Groups
I’m fairly new to Laravel, so this question may obvious to some. In the case of running checks per HTTP request, for example User Authentication. Is there a better, more efficient or simple correct …