One of the primary roles of a module is to provide an interface to manage content. By using the
make:stream command we can very quickly scaffold our streams data structures, CRUD, and various services for interacting with the streams data.
For the purpose of demonstration we will stick to the
library module provided as an example in the Creating a Module tutorial.
Creating a Stream
To create a stream use the
make:stream command and specify the
slug of the desired stream and
addon to generate the stream in:
php artisan make:stream books my_project.module.library
A migration will be generated in the
/migrations directory of your addon for specifying stream details and field assignments:
You can edit the migration to configure the stream the migration creates and the fields that are assigned to it.
Routes and Controller
A routes file named after your stream will be generated in the
/resources/routes directory of your addon. The routes will provide default
edit. You can copy these into your addon service provider or leave them here.
A controller named after your stream will also be generated in the
/src/Http/Controller/Admin directory of your addon. This controller by default handled the CRUD routes mentioned above.
A new namespace directory for your stream will be created in the
/src directory of your addon. The various classes there are covered in other tutorials for their respective services.
Book/Contract/BookInterface.php Book/Contract/BookRepositoryInterface.php Book/Form/BookFormBuilder.php Book/Table/BookTableBuilder.php Book/BookCollection.php Book/BookCriteria.php Book/BookModel.php Book/BookObserver.php Book/BookPresenter.php Book/BookRepository.php Book/BookRouter.php