Answer the question
In order to leave comments, you need to log in
How, after creating an article using the store method, go directly to the page from its display?
There is a store method
public function store(AdRequest $request)
{
Ad ::create([
'title' => $request->title,
'description' => $request->description,
'user_id' => Auth::user()->id,
'author_name' => Auth::user()->username
]);
}
@if (count($ad) > 1)
@foreach ($ad as $a)
<div class="card-header mb-3">
<h3><a href="{{ route('adShow', ['id'=>$a->id]) }}">{{ $a->title }}</a></h3>
<p>{{ $a->description }}</p>
<small>Author name: {{ $a->author_name }}</small><br/>
<small>Created At {{ $a->created_at }}</small>
</div>
@endforeach
public function show($id)
{
$oneAd = Ad::find($id);
return view('ad-content', [
'oneAd' => $oneAd
]);
}
<div class="card-header mb-3">
<h3>{{ $oneAd->title }}</h3>
<p>{{ $oneAd->description }}</p>
<small>Author name: {{ $oneAd->author_name }}</small><br/>
<small>Created At {{ $oneAd->created_at }}</small>
</div>
Route::get('/{id}', '[email protected]')->name('adShow');
Answer the question
In order to leave comments, you need to log in
How to make it so that ... move
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question