Support the ongoing development of Laravel.io →
Authentication Session Database
Last updated 2 years ago.
0

get the current user id $id_current = Auth::user()->id;

0

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

Last updated 7 years ago.
0

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();
                }
      }

}
0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ndar0430 ndar0430 Joined 23 Feb 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.