0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

laravelのbladeでapp.phpにエイリアスを定義せずにconst使う

Posted at

app.phpにエイリアス定義したくなかった系です。

blade
@php
use App\Enums\HogeCode;
@endphp

{{HogeCode::teacher}}
HogeCode
<?php

namespace App\Enums;

final class HogeCode
{
    // 定数メンバ
    const student = 1;
    const teacher = 2;

    // key/valueの連想配列
    const enum = [
        self::student=>'生徒',
        self::teacher=>'先生',
    ];
}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?