120 lines
2.6 KiB
PHP
120 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Auth\Authenticatable;
|
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Laravel\Lumen\Auth\Authorizable;
|
|
use Laravel\Passport\HasApiTokens;
|
|
use SMartins\PassportMultiauth\HasMultiAuthApiTokens;
|
|
|
|
/**
|
|
* Class Agent
|
|
*
|
|
* @property int $id
|
|
* @property string $uid
|
|
* @property string $firstname
|
|
* @property string $lastname
|
|
* @property string $email
|
|
* @property float $longitude
|
|
* @property float $latitude
|
|
* @property string $adresse
|
|
* @property float $balance
|
|
* @property string $encrypted_password
|
|
* @property string $salt
|
|
* @property int $active
|
|
* @property Carbon $date_created
|
|
* @property Carbon $open_hours
|
|
* @property Carbon $close_hours
|
|
* @property int $town_id
|
|
* @property int $number_super
|
|
* @property int $number_geoBysuper
|
|
*
|
|
* @property Town $town
|
|
*
|
|
* @package App\Models
|
|
*/
|
|
class Agent extends Model implements AuthenticatableContract, AuthorizableContract
|
|
{
|
|
use HasMultiAuthApiTokens, Authenticatable, Authorizable;
|
|
|
|
protected $table = 'agents';
|
|
public $timestamps = false;
|
|
|
|
protected $casts = [
|
|
'longitude' => 'float',
|
|
'latitude' => 'float',
|
|
'balance' => 'float',
|
|
'active' => 'int',
|
|
'town_id' => 'int',
|
|
'number_super' => 'int',
|
|
'number_geoBysuper' => 'int'
|
|
];
|
|
|
|
protected $dates = [
|
|
'date_created',
|
|
'open_hours',
|
|
'close_hours'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'encrypted_password'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'uid',
|
|
'firstname',
|
|
'lastname',
|
|
'email',
|
|
'longitude',
|
|
'latitude',
|
|
'adresse',
|
|
'balance',
|
|
'encrypted_password',
|
|
'salt',
|
|
'active',
|
|
'date_created',
|
|
'open_hours',
|
|
'close_hours',
|
|
'town_id',
|
|
'number_super',
|
|
'number_geoBysuper'
|
|
];
|
|
|
|
public function town()
|
|
{
|
|
return $this->belongsTo(Town::class);
|
|
}
|
|
|
|
/**
|
|
* Find the user instance for the given username.
|
|
*
|
|
* @param string $username
|
|
* @return \App\Models\User
|
|
*/
|
|
public function findForPassport($username)
|
|
{
|
|
return $this->where('email', $username)->first();
|
|
}
|
|
|
|
/**
|
|
* Validate the password of the user for the Passport password grant.
|
|
*
|
|
* @param string $password
|
|
* @return bool
|
|
*/
|
|
public function validateForPassportPasswordGrant($password)
|
|
{
|
|
// return Hash::check($password, $this->password);
|
|
$encrypted_password = base64_encode(sha1($password . $this->salt, true) . $this->salt);
|
|
return $this->encrypted_password == $encrypted_password;
|
|
}
|
|
}
|