vendredi 11 novembre 2016

Error retrieving data after using slug (Laravel 5.3)

I have problem accessing a page that is using slug url, previously when just using id it worked just fine.

Route : Route::get('journal/{journalslug}', 'JournalController@show');

URL : href="

Controller :

public function show($journalslug) {
        $journal = Journal::where('journalslug','=',$journalslug)->get();
        return view('journal/show', compact('journal', $journal));
    }

View :

<div class="large-widget m30">
                    <div class="post-desc">
                        <h2 style="text-align: center;"></h2>
                        <p style="text-align: center;"><strong>
                                @foreach($journal->user as $item)
                                ,
                                @endforeach
                        </strong></p>
                        <p style="text-align: center;"><strong>Abstract :</strong></p>
                        <p>{!! $journal->abstract !!}</p>
                        <p style="text-align: center;"><a href="" style="color : #00569d;">View Journal</a></p>
                    </div><!-- end post-desc -->
                </div><!-- end large-widget -->

Error :

Undefined property: Illuminate\Database\Eloquent\Collection::$title (View: C:\xampp\htdocs\2mark\resources\views\journal\show.blade.php)

I don't know what I did wrong, need your help guys, thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire