Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
20.00% |
1 / 5 |
|
20.00% |
1 / 5 |
CRAP | |
0.00% |
0 / 1 |
| VendorApplication | |
20.00% |
1 / 5 |
|
20.00% |
1 / 5 |
17.80 | |
0.00% |
0 / 1 |
| approvedBy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| vendor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| scopePending | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| scopeApproved | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| scopeRejected | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | |
| 7 | /** |
| 8 | * Self-onboarding: a prospective vendor fills out a public application form. |
| 9 | * Admin reviews → approve (creates a Vendor + User) or reject. |
| 10 | */ |
| 11 | class VendorApplication extends Model |
| 12 | { |
| 13 | protected $fillable = [ |
| 14 | 'name', 'email', 'phone', 'store_name', |
| 15 | 'address', 'nid_number', 'bio', |
| 16 | 'status', 'rejection_reason', |
| 17 | 'approved_by', 'vendor_id', |
| 18 | ]; |
| 19 | |
| 20 | /* ─── Relationships ─── */ |
| 21 | |
| 22 | public function approvedBy() |
| 23 | { |
| 24 | return $this->belongsTo(User::class, 'approved_by'); |
| 25 | } |
| 26 | |
| 27 | public function vendor() |
| 28 | { |
| 29 | return $this->belongsTo(Vendor::class); |
| 30 | } |
| 31 | |
| 32 | /* ─── Scopes ─── */ |
| 33 | |
| 34 | public function scopePending($q) |
| 35 | { |
| 36 | return $q->where('status', 'pending'); |
| 37 | } |
| 38 | |
| 39 | public function scopeApproved($q) |
| 40 | { |
| 41 | return $q->where('status', 'approved'); |
| 42 | } |
| 43 | |
| 44 | public function scopeRejected($q) |
| 45 | { |
| 46 | return $q->where('status', 'rejected'); |
| 47 | } |
| 48 | } |