Until today i was working with Controller-Model (CodeIgniter for example) or Controller-Service-Gateway (Symfony2 components) logic, but now when i am trying to learn Laravel, i've noticed what in beginner tutorials we use only Controller + Eloquent model, so at this moment i have a question, is it really what all logic in Laravel is processed in Controller, or i must find another tutorials.
For example by my "old" logic here i want to get all Articles not in controller, but in service/model, and then return edited array back to controller, and then pass it to a view.
In short: Controllers passes to a View data returned by Service, and in Laravel i don't see any services
<?php namespace Testous\Http\Controllers;
use Testous\Models\Articles;
class WelcomeController extends Controller {
public function __construct()
{
}
public function index()
{
dd(Articles::all());
return view('app');
}
}
You can structure you application however you want, service layer, repositories and decorators etc... nothing is set in stone.
jacksoncharles said:
You can structure you application however you want, service layer, repositories and decorators etc... nothing is set in stone.
Thank you, and is there is something like defining service in config for IoC/DI ?
(disclaimer: i'm still pretty new to laravel)
just define your class anywhere you want (e.g. App\YourPackage\Service\Foo) and bind it to the service container via App::bind().
it is pretty well documented: http://laravel.com/docs/5.0/providers http://laravel.com/docs/5.0/container
DaHaiz said:
(disclaimer: i'm still pretty new to laravel)
just define your class anywhere you want (e.g. App\YourPackage\Service\Foo) and bind it to the service container via App::bind().
it is pretty well documented: http://laravel.com/docs/5.0/providers http://laravel.com/docs/5.0/container
Thank you !
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community