partial update opnames and detail table
This commit is contained in:
@@ -23,9 +23,7 @@ class Dealer extends Model
|
||||
return $this->hasMany(Transaction::class, 'dealer_id', 'id');
|
||||
}
|
||||
|
||||
public function products(){
|
||||
return $this->belongsToMany(Product::class, 'stock')
|
||||
->withPivot('quantity')
|
||||
->withTimestamps();
|
||||
public function opnames(){
|
||||
return $this->hasMany(Opname::class);
|
||||
}
|
||||
}
|
||||
|
||||
26
app/Models/Opname.php
Normal file
26
app/Models/Opname.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Opname extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = ['dealer_id','opname_date','user_id','note'];
|
||||
|
||||
public function dealer(){
|
||||
return $this->belongsTo(Dealer::class);
|
||||
}
|
||||
|
||||
public function details(){
|
||||
return $this->hasMany(OpnameDetail::class);
|
||||
}
|
||||
|
||||
public function user(){
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
30
app/Models/OpnameDetail.php
Normal file
30
app/Models/OpnameDetail.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class OpnameDetail extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $fillable = [
|
||||
'opname_id',
|
||||
'product_id',
|
||||
'physical_stock',
|
||||
'system_stock',
|
||||
'difference',
|
||||
'note',
|
||||
];
|
||||
|
||||
public function opname()
|
||||
{
|
||||
return $this->belongsTo(Opname::class);
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,7 @@ class Product extends Model
|
||||
return $this->belongsTo(ProductCategory::class, 'product_category_id');
|
||||
}
|
||||
|
||||
public function dealers(){
|
||||
return $this->belongsToMany(Dealer::class, 'stock')
|
||||
->withPivot('quantity')
|
||||
->withTimestamps();
|
||||
public function opnameDetails(){
|
||||
return $this->hasMany(OpnameDetail::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user