I have a from group row with a dropdown that automatically fills with data form the table "clients".
<label for="client" class="text-muted font-weight-light text-center">{{ __('Client') }}</label>
<div class="form-group row">
<div class="col-md-12">
<select class="form-control" id="user" name="user">
@foreach($clients as $client)
<option value="{{$client->id}}">{{$client->firstname}} {{$client->lastname}} - {{$client->residence}} ({{$client->housing}} {{$client->housenr}})</option>
@endforeach
</select>
</div>
</div>
this POST form pushes a whole form to a table named "tasks". Now the problem is that I'm using in this blade (for example) {{$client->residence}}
, but I need to be able to do that in my controller in my insert function to push it to the database.
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function insert(Request $request)
{
$clients = Clients::All();
$id = auth()->user()->id;
$title = $request->input('title');
$startdate = $request->input('startdate');
$enddate = $request->input('enddate');
$starttime = $request->input('starttime');
$endtime = $request->input('endtime');
$description = $request->input('description');
$data=array(
"uuid"=>$id,
"title"=>$title,
"client"=>$client,
"startdate"=>$startdate,
"enddate"=>$enddate,
"starttime"=>$starttime,
"endtime"=>$endtime,
"description"=>$description);
DB::table('tasks')->insert($data);
return redirect('/todo');
}
So what I would like to do is use the selected {{$client->id}}
to get the information to push it to the task table in separate columns.
Hopefully it is clear what I mean.