I need to hand over a Variable ($id) from my "KundenController" to my "ServerController" to link the id of "kunden" to "kunden_id" in my server colum.
Could you help me with that please? im totally stuck
public function store() //KundenController
{
$this->validate(request(), [
'name'=>'required',
'RAM'=>'required',
'CPUAnzahl'=>'required',
'CPUBezeichnung'=>'required',
'Festplatte1'=>'required'
]);
$server = new Server;
$kunden = new Kunden;
$server->name = request('name');
$server->RAM = request('RAM');
$server->CPUAnzahl = request('CPUAnzahl');
$server->CPUBezeichnung = request('CPUBezeichnung');
$server->Festplatte1 = request('Festplatte1');
$server->save();
return redirect('/server/index');
}
public function store() //ServerController
{
$this->validate(request(), [
'name'=>'required',
'RAM'=>'required',
'CPUAnzahl'=>'required',
'CPUBezeichnung'=>'required',
'Festplatte1'=>'required'
]);
$server = new Server;
$kunden = new Kunden;
$server->name = request('name');
$server->RAM = request('RAM');
$server->CPUAnzahl = request('CPUAnzahl');
$server->CPUBezeichnung = request('CPUBezeichnung');
$server->Festplatte1 = request('Festplatte1');
$server->save();
return redirect('/server/index');
}
so i need to get smth like $server->KundenID = request($kunden->id); but thats not working. First time working with Laravel in PHP it would be kinda simple
via n1ghty