Download core/app/Models/Cart.php from pnacorp/promptlab: direct link, hf CLI and curl.
- Browser
- Download file 771 Bytes
-
https://huggingface.co/pnacorp/promptlab/resolve/main/core/app/Models/Cart.php
- Command line
-
hf download hf://pnacorp/promptlab/core/app/Models/Cart.php
-
curl -L -o Cart.php https://huggingface.co/pnacorp/promptlab/resolve/main/core/app/Models/Cart.php
771 Bytes
| namespace App\Models; | |
| use App\Constants\Status; | |
| use Illuminate\Database\Eloquent\Factories\HasFactory; | |
| use Illuminate\Database\Eloquent\Model; | |
| class Cart extends Model | |
| { | |
| use HasFactory; | |
| protected $guarded = []; | |
| public function prompt() | |
| { | |
| return $this->belongsTo(Prompt::class, 'prompt_id'); | |
| } | |
| public static function subtotal() | |
| { | |
| return self::where('user_id', auth()->id()) | |
| ->whereHas('prompt', function ($prompt) { | |
| $prompt->approved(); | |
| }) | |
| ->sum('price'); | |
| } | |
| public static function cartItems() | |
| { | |
| return self::where('user_id', auth()->id()) | |
| ->whereHas('prompt', function ($prompt) { | |
| $prompt->approved(); | |
| }) | |
| ->get(); | |
| } | |
| } | |