Download core/app/Models/Order.php from pnacorp/codeplus: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/pnacorp/codeplus/resolve/main/core/app/Models/Order.php
- Command line
-
hf download hf://pnacorp/codeplus/core/app/Models/Order.php
-
curl -L -o Order.php https://huggingface.co/pnacorp/codeplus/resolve/main/core/app/Models/Order.php
1.51 kB
| namespace App\Models; | |
| use App\Constants\Status; | |
| use Illuminate\Database\Eloquent\Casts\Attribute; | |
| use Illuminate\Database\Eloquent\Model; | |
| class Order extends Model | |
| { | |
| public function product() | |
| { | |
| return $this->belongsTo(Product::class); | |
| } | |
| public function user() | |
| { | |
| return $this->belongsTo(User::class); | |
| } | |
| public function seller() | |
| { | |
| return $this->belongsTo(User::class, 'seller_id', 'id'); | |
| } | |
| public function scopeGatewayCurrency() | |
| { | |
| return GatewayCurrency::where('method_code', $this->method_code)->where('currency', $this->method_currency)->first(); | |
| } | |
| public function gateway() | |
| { | |
| return $this->belongsTo(Gateway::class, 'method_code', 'code'); | |
| } | |
| public function orderItems() | |
| { | |
| return $this->hasMany(OrderItem::class); | |
| } | |
| public function scopePaid($query) | |
| { | |
| return $query->where('payment_status', Status::ORDER_PAID); | |
| } | |
| public function buyer() | |
| { | |
| return $this->belongsTo(User::class); | |
| } | |
| public function paymentStatusBadge(): Attribute | |
| { | |
| return new Attribute(function () { | |
| $html = ''; | |
| if ($this->payment_status == Status::ORDER_PAID) { | |
| $html = '<span class="badge badge--success">' . trans('Paid') . '</span>'; | |
| } else { | |
| $html = '<span class="badge badge--danger">' . trans('Unpaid') . '</span>'; | |
| } | |
| return $html; | |
| }); | |
| } | |
| } | |