I am having trouble displaying data in the View from arrays in my DB, I have tried multiple methods to no avail. I need to display all of the results in the View from both arrays in the DB (Name and Url) - I have tried for loops although I can't seem to target the data correctly. I also do not know where I am going wrong in my code. I am new to Laravel.
Any help would be appreciated.
DB Instance:
local.INFO: array (
'_token' => 'kwsRPOc9YH4pjvmAVsibJULiMUItzZu2BEWimJy6',
'name' =>
array (
0 => 'linkOne',
1 => 'linkTwo',
),
'url' =>
array (
0 => 'urlOne',
1 => 'urlTwo',
),
)
Controller:
public function addMorePost(TagList $tagslist, Request $request)
{
Log::info($request);
foreach($request as $key => $value) {
TagList::create([
'name[]'=>[$value],
'url[]'=>[$value]
]);
}
$tagslist = \App\Taglist::all();
return view('addMore', ['tagslist' => $tagslist]);
}
View:
@foreach ($tagslist as $tag)
<div>
<p class="name">{{ $tag->name }}</p>
<p class="url">{{ $tag->url }}</p>
</div>
@endforeach