PHP code example of mennovanhout / laravel-model-constants

1. Go to this page and download the library: Download mennovanhout/laravel-model-constants library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mennovanhout / laravel-model-constants example snippets




namespace Domain\Authentication\Models;

use MennoVanHout\LaravelModelConstants\Types\ModelAttributes;

class UserAttributes extends ModelAttributes
{
	 const ID = 'id';
	 const NAME = 'name';
	 const EMAIL = 'email';
	 const EMAIL_VERIFIED_AT = 'email_verified_at';
	 const PASSWORD = 'password';
	 const REMEMBER_TOKEN = 'remember_token';
	 const CREATED_AT = 'created_at';
	 const UPDATED_AT = 'updated_at';
}



namespace Domain\Authentication\Models;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

    protected $fillable = [
        UserAttributes::NAME,
        UserAttributes::EMAIL,
        UserAttributes::PASSWORD,
    ];

    protected $hidden = [
        UserAttributes::PASSWORD,
        UserAttributes::REMEMBER_TOKEN,
    ];

    protected $casts = [
        UserAttributes::EMAIL_VERIFIED_AT => 'datetime',
    ];
}