Skip to content
Advertisement

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-new-in-laravel-5/episodes/2 2) Here is simple implementation of method injection you can also look at function in https://github.com/laravel/framework/blob/master/src/Illuminate/Container/Container.php file for more details 3) You can

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 insert a new

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

Dropping column with foreign key Laravel error: General error: 1025 Error on rename

I’ve created a table using migration like this: I need to change this table and drop the foreign key reference & column pick_detail_id and add a new varchar column called sku after pick_id column. So, I’ve created another migration, which looks like this: When I run this migration, I get the following error: [IlluminateDatabaseQueryException] SQLSTATE[HY000]: General error: 1025 Error on

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 should be using Method or Constructor injection. This will

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: What am

Laravel Mail::send() sending to multiple to or bcc addresses

I can’t seem to successfully send to multiple addresses when using Laravel’s Mail::send() callback, the code does however work when I only specify one recipient. I’ve tried chaining: and passing an array: but neither seem to work and I get failure messages when returning Mail::failures(), a var_dump() of Mail::failures() shows the email addresses that I tried to send to, for

Advertisement