Download core/app/Models/User.php from pnacorp/promptlab: direct link, hf CLI and curl.
- Browser
- Download file 4.13 kB
-
https://huggingface.co/pnacorp/promptlab/resolve/main/core/app/Models/User.php
- Command line
-
hf download hf://pnacorp/promptlab/core/app/Models/User.php
-
curl -L -o User.php https://huggingface.co/pnacorp/promptlab/resolve/main/core/app/Models/User.php
4.13 kB
| namespace App\Models; | |
| use App\Constants\Status; | |
| use App\Traits\UserNotify; | |
| use Illuminate\Database\Eloquent\Casts\Attribute; | |
| use Illuminate\Foundation\Auth\User as Authenticatable; | |
| use Laravel\Sanctum\HasApiTokens; | |
| class User extends Authenticatable | |
| { | |
| use HasApiTokens, UserNotify; | |
| /** | |
| * The attributes that should be hidden for arrays. | |
| * | |
| * @var array | |
| */ | |
| protected $hidden = [ | |
| 'password', | |
| 'remember_token', | |
| 'ver_code', | |
| 'balance', | |
| 'kyc_data' | |
| ]; | |
| /** | |
| * The attributes that should be cast to native types. | |
| * | |
| * @var array | |
| */ | |
| protected $casts = [ | |
| 'email_verified_at' => 'datetime', | |
| 'kyc_data' => 'object', | |
| 'ver_code_send_at' => 'datetime' | |
| ]; | |
| public function prompts() | |
| { | |
| return $this->hasMany(Prompt::class, 'user_id')->where('status', Status::PROMPT_APPROVED); | |
| } | |
| public function sales() | |
| { | |
| return $this->hasManyThrough(OrderDetails::class, Prompt::class, 'user_id', 'prompt_id', 'id', 'id') | |
| ->join('orders', 'order_details.order_id', '=', 'orders.id') | |
| ->select('order_details.*', 'orders.*') | |
| ->with('prompt'); | |
| } | |
| public function sells() | |
| { | |
| return $this->hasManyThrough(OrderDetails::class, Order::class, 'user_id', 'order_id', 'id', 'id') | |
| ->where('orders.status', Status::ORDER_COMPLETED); | |
| } | |
| public function purchases() | |
| { | |
| return $this->hasManyThrough(OrderDetails::class, Order::class, 'user_id', 'order_id', 'id', 'id') | |
| ->where('orders.status', Status::ORDER_COMPLETED); | |
| } | |
| public function loginLogs() | |
| { | |
| return $this->hasMany(UserLogin::class); | |
| } | |
| public function transactions() | |
| { | |
| return $this->hasMany(Transaction::class)->orderBy('id', 'desc'); | |
| } | |
| public function deposits() | |
| { | |
| return $this->hasMany(Deposit::class)->where('status', '!=', Status::PAYMENT_INITIATE); | |
| } | |
| public function withdrawals() | |
| { | |
| return $this->hasMany(Withdrawal::class)->where('status', '!=', Status::PAYMENT_INITIATE); | |
| } | |
| public function tickets() | |
| { | |
| return $this->hasMany(SupportTicket::class); | |
| } | |
| public function fullname(): Attribute | |
| { | |
| return new Attribute( | |
| get: fn() => $this->firstname . ' ' . $this->lastname, | |
| ); | |
| } | |
| public function mobileNumber(): Attribute | |
| { | |
| return new Attribute( | |
| get: fn() => $this->dial_code . $this->mobile, | |
| ); | |
| } | |
| public function follows() | |
| { | |
| return $this->hasMany(Follow::class, 'user_id'); | |
| } | |
| public function followers() | |
| { | |
| return $this->hasMany(Follow::class, 'followed_user_id'); | |
| } | |
| public function isFollowing($userId) | |
| { | |
| return $this->follows()->where('followed_user_id', $userId)->exists(); | |
| } | |
| // SCOPES | |
| public function scopeActive($query) | |
| { | |
| return $query->where('status', Status::USER_ACTIVE)->where('ev', Status::VERIFIED)->where('sv', Status::VERIFIED); | |
| } | |
| public function scopeBanned($query) | |
| { | |
| return $query->where('status', Status::USER_BAN); | |
| } | |
| public function scopeEmailUnverified($query) | |
| { | |
| return $query->where('ev', Status::UNVERIFIED); | |
| } | |
| public function scopeMobileUnverified($query) | |
| { | |
| return $query->where('sv', Status::UNVERIFIED); | |
| } | |
| public function scopeKycUnverified($query) | |
| { | |
| return $query->where('kv', Status::KYC_UNVERIFIED); | |
| } | |
| public function scopeKycPending($query) | |
| { | |
| return $query->where('kv', Status::KYC_PENDING); | |
| } | |
| public function scopeEmailVerified($query) | |
| { | |
| return $query->where('ev', Status::VERIFIED); | |
| } | |
| public function scopeMobileVerified($query) | |
| { | |
| return $query->where('sv', Status::VERIFIED); | |
| } | |
| public function scopeWithBalance($query) | |
| { | |
| return $query->where('balance', '>', 0); | |
| } | |
| public function deviceTokens() | |
| { | |
| return $this->hasMany(DeviceToken::class); | |
| } | |
| } | |