Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
456 views
in Technique[技术] by (71.8m points)

Laravel Breadcrumbs with parameter DaveJamesMiller

Hi im having trouble with laravel breadcrumbs. I pass value from blade file something like this.

//parent page
<a href="{{ route('test.index',$subject->id) }}" class="btn" id="btn_test_available">View tests available</a>

then routes/web.php like this.

Route::get('/general_test', 'SubjectController@index')->name('admin_general_test'); //parent 
Route::get('/general_test/index/{id}', 'ExamController@index')->name('test.index'); //child

I installed breadcrumbs successfully and working but i cant figure out how the parameters works.

Here is my routes/breadcrumbs.php

Breadcrumbs::for('admin_general_test', function ($trail) {
    $trail->push('Parent', route('admin_general_test'));
});

Breadcrumbs::for('test.index', function ($trail,$subject) {
    $trail->parent('admin_general_test');
    $trail->push('Child', route('test.index',$subject));
});

and finally fetched breadcrumbs like this

//child page
{{ Breadcrumbs::render('test.index') }}

I cant figure out what is wrong as is throws error Too few arguments to function DaveJamesMillerBreadcrumbsBreadcrumbsServiceProvider::{closure}...... I followed step by step process in git hub but seems no luck. How I could possibly make it work with parameters? Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...