<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
class AdminModel extends Authenticatable
{
    protected $table='admin';

    protected $fillable=[
      'name',
      'email',
      'password',
      'role',
      'appcount',
    ];


    public function logAdmin($trigger, $activity_type, $message, $client = null)
    {

        return AuditTrail::query()->create([
            'triggered_by' => $trigger.' ('.$this->findRole().')',
            'client_id' => $client,
            'admin_id' => $this->id,
            'message' => $this->name.' '.$message,
            'activity_type' => $activity_type

        ]);
    }

//auth()->guard('adminguard')->user()->logAdmin("View Evaluation Form", 'View Evaluation Form', 'Viewed evaluation form of Client: '.$log_user->name, $log_user->id);


    public function findRole()
    {

        $role = '';

        if ($this->role === '1'){
            $role = 'Super Admin';
        }

        if ($this->role === '2'){
            $role = 'Project Analyst';
        }

        if ($this->role === '3'){
            $role = 'Credit Analyst';
        }

        return $role;

    }
}
