Skip to content

Tag: laravel

Laravel 5 – Method injection

How method injection works in Laravel 5(I mean implementation), can I inject parameters in custom method, not just in controller actions? Answer 1) Read this articles to know more about method injection in laravel 5 http://mattstauffer.co/blog/laravel-5.0-method-injection https://laracasts.com/series/whats-ne…

How to insert a new value into lang file with Laravel 4

I knew that Laravel has Lang::get(‘xxx’); function But when the string xxx was not an key in the lang array => it will just display xxx, then I have to manually type a new key => value into the lang file. So is there anyway that if xxx not available in the lang file, it will automatically in…

Laravel – Testing what happens after a redirect

I have a controller that after submitting a email, performs a redirect to the home, like this: I am writing the tests for it, and I am not sure how to make phpunit to follow the redirect, to test the success message: If I substitute the code on the controller for this, and I remove the first 2 asserts, it

Laravel 5 how to get route action name?

I’m trying to get the current route action, but I’m not sure how to go about it. In Laravel 4 I was using Route::currentRouteAction() but now it’s a bit different. I’m trying to do Route::getActionName() in my controller but it keeps giving me method not found. Answer In Laravel 5 you …

Laravel belongsTo returning null when using ‘with’

I’m just getting started with Laravel so please forgive any noobness. I have a User and Order model, a user has many orders: So I think I have the above right. But when I do this: I get Call to a member function addEagerConstraints() on null. However, if I do it the other way around, it works great: Wha…