I'm still a newbie in Laravel, I'm using Laravel 4.2 Is there a way where if the author_ID is matched with Auth::ID it will show the specific line of codes
Code example:
@if ($data['authorID'] == Auth::id())
<a href="@{{invoice_url}}" target="_blank">
@{{payment_date | date:_dateFormat.shortDate}}
</a>
@else
<p>@{{payment_date | date:_dateFormat.shortDate}}</p>
@endif
Where author_id's data is this
$data['authorID'] = [
author_id => 5,
author_id => 2
]
CodePudding user response:
you should use in_array like this example
$people = array("Peter","Joe","Glenn","Cleveland");
if (in_array("Glenn", $people))
{ echo "Match found"; }
else{ echo "Match not found"; }
CodePudding user response:
try this
@if (in_array(Auth::id(),$data['authorID']))
<a href="@{{invoice_url}}" target="_blank">
@{{payment_date | date:_dateFormat.shortDate}}
</a>
@else
<p>@{{payment_date | date:_dateFormat.shortDate}}</p>
@endif