Skip to content

Instantly share code, notes, and snippets.

@YavorK
Created December 9, 2016 16:38
Show Gist options
  • Save YavorK/0b24ace3000cc70b94515954ff6dc11a to your computer and use it in GitHub Desktop.
Save YavorK/0b24ace3000cc70b94515954ff6dc11a to your computer and use it in GitHub Desktop.
Helpers file from a "random" Laravel project
<?php
use Illuminate\Support\Facades\Route;
function path_to_user_profile_image($filename)
{
if ($filename != '') {
return url('img/children/' . $filename);
}
return url('img/default_child.png');
}
function path_to_user_profile_retina_image($filename)
{
if ($filename != '') {
return url('img/children/retina_' . $filename);
}
return url('img/default_child.png');
}
function path_to_dish_image($filename)
{
if (empty($filename)) {
return url('img/default.png');
}
return url('img/dishes/' . $filename);
}
function path_to_dish_retina_image($filename)
{
if (empty($filename)) {
return url('img/default.png');
}
return url('img/dishes/retina_' . $filename);
}
function getClassIfActive($route)
{
if (Route::currentRouteName() == $route) {
return 'active';
} else {
return '';
}
}
function t($key)
{
return trans($key);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment