Skip to content

Instantly share code, notes, and snippets.

@segovia94
Last active September 28, 2015 18:38
Show Gist options
  • Save segovia94/b1fe94c975d40faa5197 to your computer and use it in GitHub Desktop.
Save segovia94/b1fe94c975d40faa5197 to your computer and use it in GitHub Desktop.
Custom Laravel Helper
<?php // resources/views/partials/_header-images.blade.php ?>
<div class="header-images">
@foreach($images as $image)
<div>{!! Html::image($image) !!}</div>
@endforeach
</div>
{
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
// Add this to the file
"files": [
"app/helpers.php"
]
},
}
<?php namespace App;
// app/helpers.php
use File;
class Helpers {
/**
* Rotating Header Images
*
* @param string $file_path
* @return array|bool
*/
static function header_images($file_path = 'images/header') {
// Generate Header Images
return $header_images;
}
}
<?php // resources/views/template.blade.php ?>
<!DOCTYPE html>
<html>
<head>
<title>Custom Laravel Helper</title>
</head>
<body>
<header class="header">
@include('partials._header-images', array($images = \App\Helpers::header_images()))
</header>
<div class="content">
@yield('content')
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment