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
Tag: laravel
PHP/Laravel – find and read ‘key-value pair’ from file
I want to store some text informations but I don’t want to use database for this. For example there is a file: key1: some text information 1 key2: some text information 2 key3: another text …
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
Cannot use IlluminateRoutingController as Controller because the name is already in use
I have been learning to use Laravel, watching Larcasts and using the Docs, I came across a lesson where Eloquent is being described but I’m stuck with the error: I’m very confused and have now copied the examples provided exactly but I still get the error. I am using Laravel 5, so I don’t know if there has been some
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 blade multiple select. How to select records in the pivot table?
I am using Laravel, and I have a projects table and a users table. Each project can have multiple users. I have set up a project_user pivot table. I am trying to create a multiselect box that lists all users, and has the users currently assigned to the project selected. Here is my ProjectsController function that creates the view. And
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