Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tables creation:
- product
- id | primary key, unsigned, integer
- kd_barang | unique, nullable, FK constraint
- nama_roti
- harga
- timestamps()
- transaksi
- id_transaksi | primary key, varchar
- kd_barang | FK Constraint to product table
- jumlah
- harga satuan
- total_harga
- timestamps
- Relationships:
- App\Product
- public function transaction()
- {
- return $this->hasMany(Transaction::class, 'kd_barang');
- }
- App\Transaction
- protected $table = 'transaksi';
- protected $primaryKey = 'id_transaksi';
- protected $fillable = ['kd_barang', 'jumlah' , 'harga_satuan', 'total_harga'];
- public $incrementing = false;
- public function product()
- {
- return $this->belongsTo(Product::class, 'kd_barang');
- }
- <a href="https://imgur.com/UZY6hJK"><img src="https://i.imgur.com/UZY6hJK.png" title="source: imgur.com" /></a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement