Controller
Artisan also create the controllers
- php artisan make:controller <Controller name>Controller
- The new controller will appers in app/Http/Contoller folder
- Add the namescape DB: use DB;
Functionallity
Create the fuction index
- public function index() {
- return view ('<view_name>.index');
- }
<view_name>.index means
- That there is a view in /resources/views/<view_name>/index.blade.php
Passing parameters
- return view ('<view_name>.index', compact('<array>') );
Other form is
- return view('<view_name>.index')->with('<array>', $<array>)
Routes
- In the file app/Http/routes indicate the controller to be used
- Route::get('notes', 'NoteController@<function>');
- 'notes' is the name of the URL
- 'NoteController is the name of the file controller
- @<method> is the function to be called
- In my case can test using the Path
- http://localhost:8080/oneran/public/notes
Request
Obtain the parameters from the request object
- Request::all()
Obtain a specific parameter
- Request::get('<parameter>');
Comentarios
Publicar un comentario