/
home
/
henzagold
/
server
/
app
/
Models
/
File Upload :
llllll
Current File: /home/henzagold/server/app/Models/Customer.php
<?php namespace App\Models; use App\Models\Selector; use App\Models\Major\Cash; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Hash; use Illuminate\Foundation\Auth\User as Authenticatable; class Customer extends Authenticatable { use HasFactory; use SoftDeletes,Selector; public $fillable = [ 'api_token', 'address', 'phone', 'fname', 'lname', 'name', 'mobile', 'rnd', 'ncode', 'notify_count', 'total_order', 'gram_level', 'percent', 'input', 'output', 'remain', 'city_id', 'new_city', 'rial_remain', 'rial_output', 'rial_input', 'reagent_id', 'type', 'open_order', 'child', 'sts', 'token_mobile', 'send_password', 'store_name', 'zone', 'pasazh_name', 'active', 'birth_date', 'marriage_date', 'image_id', 'mcode', 'sts_verify_step_one', 'sts_verify_step_two', 'is_archive', 'business_license_image_id',//عکس جواز کسب 'shop_image_id',//عکس از سر در فروشگاه 'ncode_image_id',//عکس کارت ملی ]; public static $STS_VERIFY_STEP_ONE = [ 1 => 'در انتظار تایید', 2 => 'تایید شده', 3 => 'رد شده', ]; public static $STS_VERIFY_STEP_TWO = [ 1 => 'در انتظار تایید', 2 => 'تایید شده', 3 => 'رد شده', ]; protected $casts = [ 'is_archive'=> 'boolean' ]; protected $attributes = [ 'active' => 1, ]; protected $hidden = ['password','send_password']; public static $TYPES = [ 1 => ' کارشناس فروش', 2 => 'مغازه دار اپلیکیشن', 3 => ' مغازه دار حضوری', 4 => 'بنکدار', ]; public static $STS = [ 1 => 'فعال', -1 => 'عدم سفارش' ]; public function setPasswordAttribute($value) { $this->attributes['password'] = Hash::make($value); } public function scopeSelectify($query) { return $query->select(['*' , 'id as to' , 'id as order_title',Customer::$SELECT_BRJ]); } public function getToAttribute($value){ return config('havaleh'); } public function getOrderTitleAttribute($value){ return Order::$STS_TAB; } public function reagent() { return $this->belongsTo('App\Models\Customer'); } public function cash() { return $this->hasMany(Cash::class) ->select(array_merge(Cash::selectWithjDate(), [Cash::$SELECT_TYPE_STR, Cash::$SELECT_STS_STR]))->orderBy('id' , 'DESC')->limit(40); } public function order() { return $this->hasMany('App\Models\Order') ->select(array_merge(Cash::selectWithjDate(), [Cash::$SELECT_TYPE_STR, Cash::$SELECT_STS_STR]))->orderBy('id' , 'DESC')->limit(40); } public function orderOne() { return $this->hasOne('App\Models\Order','customer_id')->where('sts',6); } public function children() { return $this->hasMany('App\Models\Order', 'reagent_id'); } public function city() { return $this->belongsTo('App\Models\City', 'city_id'); } public function getRemainAttribute($value) { //return $value; return Utility::round($value); } public function getGramsSellAttribute($value) { //return $value; return Utility::round($value); } public function scopeActive($query) { return $query->where('active',1); } public function image() { return $this->belongsTo('App\Models\Image'); } public function business_license_image() { return $this->belongsTo(Image::class,'business_license_image_id'); } public function shop_image() { return $this->belongsTo(Image::class,'shop_image_id'); } public function ncode_image() { return $this->belongsTo(Image::class,'ncode_image_id'); } public function workshop() { return $this->hasOne(Workshop::class,'user_id','id'); } }
Copyright ©2k19 -
Hexid
|
Tex7ure