File manager - Edit - /var/www/payraty/inventory_main/app/Models/PurchaseItem.php
Back
<?php namespace App\Models; use App\Traits\CreatedByRelationship; use App\Traits\CreatedUpdatedBy; use App\Traits\UpdatedByRelationship; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use App\Scopes\OrganisationScope; /** * PurchaseItem */ class PurchaseItem extends Model { use HasFactory, CreatedByRelationship, UpdatedByRelationship, CreatedUpdatedBy; /** * fillable * * @var array */ protected $fillable = [ 'organisation_id', 'purchase_id', 'product_stock_id', 'product_id', 'quantity', 'price', 'note', 'sub_total', 'created_by', 'updated_by', ]; protected static function booted() { static::addGlobalScope(new OrganisationScope); // Automatically set the organisation_id before creating the model static::creating(function ($model) { if (auth()->check()) { $model->organisation_id = auth()->user()->organisation_id; } }); } /** * purchase * * @return void */ public function purchase() { return $this->belongsTo(Purchase::class); } /** * product * * @return void */ public function product() { return $this->belongsTo(Product::class); } /** * receiveItems * * @return void */ public function receiveItems() { return $this->hasMany(PurchaseItemReceive::class); } /** * returnItem * * @return void */ public function returnItem() { return $this->hasMany(PurchaseReturnItem::class); } public function productStock(): BelongsTo { return $this->belongsTo(ProductStock::class); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 1.02 |
proxy
|
phpinfo
|
Settings