Maamria said:
get the current user id $id_current = Auth::user()->id;
when i click the submit button nothing happens
this is my code
public function store(Request $request)
{
$id_current = Auth::user()->id;
$rfq_table = $request->except(['RFQremarkID', 'tenderedPlanID', 'RFAID' ]);
return redirect()->route('rfq.index');
}
my inputs http://imgur.com/bkzjapl
and my database http://imgur.com/Us4l4eN
look down full code to insert data in table with current user id
public function store(Request $request)
{
$add_del = new \App\NameTable();
$add_del->name_row = Auth::user()->id;
$add_del->name_row = $request->input('name_input_here');
$add_del->name_row = $request->input('name_input_here');
$add_del->name_row = $request->input('name_input_here');
//rules exception validation
$rules= [
//not required validation of current user id
"name_input_here" => "required ",
"name_input_here" => "required|unique:mdelegues,email_del",
"name_input_here" => "required",
];
$validate = Validator::make($request->all(), $rules);
//if use translate language
$validate -> SetAttributeNames([
//path of file language and name input
"name_input_here" => trans('main.name_trans'),
"name_input_here" => trans('main.name_trans'),
"name_input_here" => trans('main.name_trans')
]);
if($validate->fails())
{
Session::flash('messageErr',"Error add record !!");
return back()->withInput()->withErrors($validate);
}
else {
if ( $add_del->save() )
{
Session::flash('messageSuccess',"Success !!");
return back();
}
}
}
Maamria said:
look down full code to insert data in table with current user id
public function store(Request $request) {
$add_del = new \App\NameTable(); $add_del->name_row = Auth::user()->id; $add_del->name_row = $request->input('name_input_here'); $add_del->name_row = $request->input('name_input_here'); $add_del->name_row = $request->input('name_input_here');
//rules exception validation $rules= [ //not required validation of current user id "name_input_here" => "required ", "name_input_here" => "required|unique:mdelegues,email_del", "name_input_here" => "required", ];
$validate = Validator::make($request->all(), $rules); //if use translate language $validate -> SetAttributeNames([ //path of file language and name input "name_input_here" => trans('main.name_trans'), "name_input_here" => trans('main.name_trans'), "name_input_here" => trans('main.name_trans') ]); if($validate->fails()) { Session::flash('messageErr',"Error add record !!"); return back()->withInput()->withErrors($validate); } else { if ( $add_del->save() ) { Session::flash('messageSuccess',"Success !!"); return back(); } }
}
got it thanks
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community