You need to run the same queries as in the other index controllers and pass it to a new view file. This can call in partials if you extract the re-usable parts from the other views.
Creating an index overview
Hi all,
I am VERY new to Laravel, but been working my way through some laracast tutorials and I am really liking it.
Working on a small project with laravel, I created an admin area. My views are stored in an "admin" folder like so:
- admin
- stages (folder)
- create.blade.php
- edit.blade.php
- index.blade.php
- show.blade.php
- teams (folder)
- create.blade.php
- edit.blade.php
- index.blade.php
- show.blade.php
- index.blade.php
- stages (folder)
I got it all to work, but now want to use the index.blade.php in the admin root to show the same content of the index files in the folders but then smaller using bootstrap. Like stages 8 rows and teams 4 rows. That way I am creating a nice interactive overview.
I tried with includes, but the problem is my controller directs variable inside the folders, giving me an error on the root index page.
ErrorException Undefined variable: stages (View: E:\laravel\Learnproject\resources\views\layouts\admin-stages.blade.php) (View: E:\laravel\Learnproject\resources\views\layouts\admin-stages.blade.php)
Stages/index.blade.php
@extends ('layouts.admin-master')
@section ('content')
@include('layouts.admin-stages')
@endsection
Admin/index.blade.php
@extends ('layouts.admin-master')
@section('content')
@include('layouts.admin-stages')
@endsection
Routes example:
// Stages summary
Route::get('admin/stages', 'StagesController@index');
//add stages
Route::get('admin/stages/create', 'StagesController@create');
Route::post('admin/stages', 'StagesController@store');
// details stages
Route::get('admin/stages/{stage}', 'StagesController@show');
//edit stages
Route::get('admin/stages/edit/{stage}', 'StagesController@edit');
Route::patch('admin/stages/update/{stage}', ['as' => 'stage.update', 'uses' => 'StagesController@update']);
//remove stages
Route::get('admin/stages/delete/{stage}', ['as' => 'stage.delete', 'uses' => 'StagesController@delete']);
I hope I could clearify my issue and that someone can help.
Kind regards TShot
Please or to participate in this conversation.