86 lines
1.6 KiB
PHP
86 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use phpDocumentor\Reflection\Types\Integer;
|
|
|
|
/**
|
|
* Class WalletTransaction
|
|
*
|
|
* @property int $id
|
|
* @property float $montant
|
|
* @property string $numCarte
|
|
* @property Carbon expiration_date
|
|
* @property int cvv
|
|
* @property string $type
|
|
* @property Carbon $date
|
|
* @property string $statut
|
|
* @property string $result
|
|
* @property int $id_wallet
|
|
*
|
|
* @property Wallet $wallet
|
|
*
|
|
* @package App\Models
|
|
*/
|
|
class WalletTransaction extends Model
|
|
{
|
|
protected $table = 'wallet_transaction';
|
|
public $timestamps = false;
|
|
|
|
protected $casts = [
|
|
'montant' => 'float',
|
|
'cvv' => 'int',
|
|
'id_wallet' => 'int'
|
|
];
|
|
|
|
protected $dates = [
|
|
'date',
|
|
'expiration_date'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'montant',
|
|
'numCarte',
|
|
'expiration_date',
|
|
'cvv',
|
|
'type',
|
|
'date',
|
|
'statut',
|
|
'result',
|
|
'id_wallet'
|
|
];
|
|
|
|
public function wallet()
|
|
{
|
|
return $this->belongsTo(Wallet::class, 'id_wallet');
|
|
}
|
|
|
|
public function getTaxeAttribute($value)
|
|
{
|
|
return ucfirst($value);
|
|
}
|
|
|
|
public function setTaxeAttribute($value)
|
|
{
|
|
$this->attributes['taxe'] = (int) $value;
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
'montant'=> 'required|numeric|min:1',
|
|
'numCarte'=>'required|integer',
|
|
'cvv'=>'required|integer|min:3|max:4',
|
|
'expiration_date'=>'required|date_format:m/Y|after_or_equal:today',
|
|
'type' =>'required|in:credit,debit',
|
|
'id_wallet' => 'required|integer|min:0'
|
|
];
|
|
}
|
|
}
|