krgm.so-manager-dev.com/app/Models/Permission.php
OU.ZAIKOU 13d2ecfceb
All checks were successful
Deploy main / deploy (push) Successful in 25s
【ログイン】二重認証実装
2026-01-21 22:37:38 +09:00

33 lines
760 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Permission extends Model
{
// テーブル名
protected $table = 'permissions';
// 主キー
protected $primaryKey = 'id';
// created_at / updated_at を使用
public $timestamps = true;
// 一括代入許可カラム
protected $fillable = [
'code', // 操作コードread/create/update/delete/export
'name', // 操作名(閲覧/登録/編集/削除/CSV出力
];
/**
* 操作コードからIDを取得存在しない場合はnull
*/
public static function idByCode(string $code): ?int
{
$row = self::query()->where('code', $code)->first(['id']);
return $row?->id;
}
}