Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| PurchaseTrait | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| storePurhcase | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| storePurhcaseDetails | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| storePurhcasePayments | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Traits; |
| 4 | |
| 5 | use App\Models\admin\Purchase; |
| 6 | use App\Models\admin\PurchaseDetails; |
| 7 | use App\Models\admin\PurchasePayment; |
| 8 | use Illuminate\Support\Facades\Auth; |
| 9 | |
| 10 | trait PurchaseTrait |
| 11 | { |
| 12 | public static function storePurhcase($purchase) |
| 13 | { |
| 14 | $data['created_by'] = ['created_by' => Auth::user()->id]; |
| 15 | $data['purchase'] = $purchase; |
| 16 | $purchase_data = array_merge($data['created_by'], $data['purchase']); |
| 17 | $purchase = Purchase::query()->create($purchase_data); |
| 18 | |
| 19 | return $purchase; |
| 20 | } |
| 21 | |
| 22 | public static function storePurhcaseDetails($data, $ref) |
| 23 | { |
| 24 | $data['purchase_details'] = $data; |
| 25 | $purchase_details_data = array_merge(['purchase_id' => $ref], $data['purchase_details']); |
| 26 | $purchase_details = PurchaseDetails::query()->create($purchase_details_data); |
| 27 | |
| 28 | return $purchase_details; |
| 29 | } |
| 30 | |
| 31 | public static function storePurhcasePayments($data, $ref) |
| 32 | { |
| 33 | $data['purchase_payment'] = $data; |
| 34 | $purchase_payment_data = array_merge(['purchase_details_id' => $ref], $data['purchase_payment']); |
| 35 | $purchase_payment = PurchasePayment::query()->create($purchase_payment_data); |
| 36 | |
| 37 | return $purchase_payment; |
| 38 | } |
| 39 | } |