専用のhelper関数を作りたい
composer.jsonの編集
composer.json
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/extensions"
],
"files": [ // <- 追加
"app/helpers.php" // <- 追加
] // <- 追加
dump-autoloadを実行
%composer dump-autoload
app/にhelpers.phpを作成
app/helpers.php
<?php
function temp_path()
{
return storage_path() . '/temp';
}
function backup_path()
{
return storage_path() . '/backup';
}
function restore_path()
{
return storage_path() . '/restore';
}
確認
app/views/index.blade.php
{{backup_path()}}
表示された。
OK