Reputation: 644
I have a problem with helpers , I create correctly the helper and I can call this helper that I created in view but when I need to access to property.
{{Text::showBanner()}};
The function of helperI created called showBanner
public static function showBanner() {
$banner= Banner::all();
return $banner;
}
How can I access to attribute id of $banner ?
UPDATED
When I use this
@foreach ( $banners as $item)
{{$item}}
@endforeach
I need to change this $banner for this helper
Upvotes: 1
Views: 72
Reputation: 1200
create a file app/helpers.php with your desired code:
function showBanner() { $banner = Banner::all(); return $banner; }
Autoload it with composer
{ "autoload": { "files": [ "app/helpers.php" ] } }
use it {{ showBanner() }}
Upvotes: 1