Thursday, March 2, 2017

Laravel how to insert my auth user id to my database upon submission?

im using laravel 5.4

upon submitting the form, the user_id of the submitter will be inserted in the database. and im not sure if its the right way so if you have any idea please help me thanks

can anyone help me please this my controller as of now.

public function index()
{
    $user = Auth::user();
    $rfq_table = $user->rfq_table;
    return view('admin.sales.rfq.index',compact('rfq_table'));
}


public function create()
{
   return view('admin.sales.rfq.create',compact('rfq_table'));
}


public function store(Request $request)
{
    $user=Auth::user();
    $rfq= $user->rfq_table()->create($request->all());
    return redirect()->route('admin.sales.rfq.index');
}




via Black Mikasa

Advertisement