mobilebackendgateway/app/Models/AgentPlus.php

131 lines
3.0 KiB
PHP
Executable File

<?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 phpDocumentor\Reflection\Types\This;
use SMartins\PassportMultiauth\HasMultiAuthApiTokens;
/**
* Class AgentPlus
*
* @property int $id
* @property string $uid
* @property string $firstname
* @property string $adresse
* @property string $lastname
* @property string $email
* @property string $encrypted_password
* @property string $salt
* @property float $longitude
* @property float $latitude
* @property string $phone
* @property int $active
* @property Carbon $created
* @property Carbon $openHours
* @property Carbon $closeHours
* @property float $solde
* @property int $etat
* @property string $network
* @property string $country
* @property string $code_parrain
* @property string $category
* @property string $code_membre
* @property int $number_geoBysuper
* @property int $network_id
* @property string $code_dial
* @property string $transactionNumber
*
* @package App\Models
*/
class AgentPlus extends Model implements AuthenticatableContract, AuthorizableContract
{
use HasMultiAuthApiTokens, Authenticatable, Authorizable;
protected $table = 'agent_plus';
public $incrementing = false;
public $timestamps = false;
protected $casts = [
'id' => 'int',
'longitude' => 'float',
'latitude' => 'float',
'active' => 'int',
'solde' => 'float',
'etat' => 'int',
'number_geoBysuper' => 'int',
'network_id' => 'int'
];
protected $dates = [
'created',
'openHours',
'closeHours'
];
protected $hidden = [
'encrypted_password'
];
protected $fillable = [
'id',
'uid',
'firstname',
'adresse',
'lastname',
'email',
'encrypted_password',
'salt',
'longitude',
'latitude',
'phone',
'active',
'created',
'openHours',
'closeHours',
'solde',
'etat',
'network',
'country',
'code_parrain',
'category',
'code_membre',
'number_geoBysuper',
'network_id',
'code_dial',
'transactionNumber'
];
/**
* Find the user instance for the given username.
*
* @param string $username
* @return \App\Models\AgentPlus
*/
public function findForPassport($username)
{
return $this->where('email', $username)->orWhere('phone', $username)->orWhere('transactionNumber', $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;
}
}