0
Working with an Laravel controller I came across something similar to this:
public function show(Role $role)
{
// é apenas um exemplo.
}
Where the Role class is instantiated in the variable $role
within the method parameter, but I can also instantiate the class as follows:
public function show()
{
$role = new Role();
}
Here comes my doubt, what would be the difference between these two ways of working, and the advantage between them?
https://coredump.pt/questions/20171048/laravel-4-inversion-of-control try reading this.
– novic
https://laravel.com/docs/5.7/controllers#dependency-Injection-and-controllers that is more complete
– novic