I want to send nama
column from Supplier
table to Transaction_in
table, but iget this error.
Illuminate\Database\Eloquent\RelationNotFoundException Call to undefined relationship [get_transactions_in] on model [App\Transaction_in].
Transaction_in Model
class Transaction_in extends Model
{
protected $guarded = [];
public function get_suppliers(){
return $this->belongsTo(Supplier::class, 'Supplier_id');
}
}
Supplier Model
class Supplier extends Model
{
protected $guarded = [];
public function get_transactions_in(){
return $this->hasMany(Transaction_in::class);
}
}
Transaction_in Controller
public function index()
{
$transaction_ins = Transaction_in::with('get_transactions_in')->get();
return view('transactionsIN.index', compact('transaction_ins', $transaction_ins, 'supplierList'));
}
The foreign key is Supplier_id
based on id
from Supplier
table.