Loading .gitignore +1 Changes for .gitignore: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -15,3 +15,4 @@ yarn-error.log /.vscode server.php index.php resources/view/test.blade.php app/Models/Role.php +16 Changes for app/Models/Role.php: 16 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Role extends Model { use HasFactory; protected $table = 'CAR_ROLE'; protected $primaryKey = 'ROL_CODE'; } app/Models/RoleAttribution.php +12 Changes for app/Models/RoleAttribution.php: 12 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class RoleAttribution extends Model { protected $table = 'CAR_ROLE_ATTRIBUTION'; public $timestamps = false; } app/Models/User.php +36 −21 Changes for app/Models/User.php: 36 added lines, 21 removed lines. Original line number Diff line number Diff line Loading @@ -7,38 +7,53 @@ use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use Illuminate\Database\Eloquent\Model; class User extends Authenticatable class User extends Model { use HasApiTokens, HasFactory, Notifiable; use HasFactory, Notifiable, HasApiTokens; protected $table = 'CAR_USER'; protected $primaryKey = 'US_ID'; /** * The attributes that are mass assignable. * Check if a given password matches the stored password. * * @var array<int, string> * @param string $password the password to try * @return bool true if the password matches, false otherwise */ protected $fillable = [ 'name', 'email', 'password', ]; public function checkPassword($password) { if($password == $this->US_PASSWORD) { return true; } else { return false; } } /** * The attributes that should be hidden for serialization. * * @var array<int, string> * Get the roles attributed to the user. */ protected $hidden = [ 'password', 'remember_token', ]; public function roles() { return $this->belongsToMany(Role::class, RoleAttribution::class, 'US_ID', 'ROL_CODE'); } /** * The attributes that should be cast. * Check if the user has a given role. * * @var array<string, string> * @param string $roleCode the code of the role to check * @return bool true if the user has the role, false otherwise */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function hasRole($roleCode) { return $this->roles->contains('ROL_CODE', $roleCode); } } ?> resources/img/Diver1.png +348 KiB Loading image diff... Loading
.gitignore +1 Changes for .gitignore: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -15,3 +15,4 @@ yarn-error.log /.vscode server.php index.php resources/view/test.blade.php
app/Models/Role.php +16 Changes for app/Models/Role.php: 16 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Role extends Model { use HasFactory; protected $table = 'CAR_ROLE'; protected $primaryKey = 'ROL_CODE'; }
app/Models/RoleAttribution.php +12 Changes for app/Models/RoleAttribution.php: 12 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class RoleAttribution extends Model { protected $table = 'CAR_ROLE_ATTRIBUTION'; public $timestamps = false; }
app/Models/User.php +36 −21 Changes for app/Models/User.php: 36 added lines, 21 removed lines. Original line number Diff line number Diff line Loading @@ -7,38 +7,53 @@ use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use Illuminate\Database\Eloquent\Model; class User extends Authenticatable class User extends Model { use HasApiTokens, HasFactory, Notifiable; use HasFactory, Notifiable, HasApiTokens; protected $table = 'CAR_USER'; protected $primaryKey = 'US_ID'; /** * The attributes that are mass assignable. * Check if a given password matches the stored password. * * @var array<int, string> * @param string $password the password to try * @return bool true if the password matches, false otherwise */ protected $fillable = [ 'name', 'email', 'password', ]; public function checkPassword($password) { if($password == $this->US_PASSWORD) { return true; } else { return false; } } /** * The attributes that should be hidden for serialization. * * @var array<int, string> * Get the roles attributed to the user. */ protected $hidden = [ 'password', 'remember_token', ]; public function roles() { return $this->belongsToMany(Role::class, RoleAttribution::class, 'US_ID', 'ROL_CODE'); } /** * The attributes that should be cast. * Check if the user has a given role. * * @var array<string, string> * @param string $roleCode the code of the role to check * @return bool true if the user has the role, false otherwise */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function hasRole($roleCode) { return $this->roles->contains('ROL_CODE', $roleCode); } } ?>