Answer the question
In order to leave comments, you need to log in
How to record the id of an authorized user?
I want to write the id of the authorized user to the table adjacent to the user, but not an object is returned, how to ask the code to work?
here is my method:
public function SalesSave(Request $req) {
$rules = [
'date' => 'required|min:4|max:36',
'earnings' => 'min:1|max:16',
];
$validator = Validator::make($req->all(), $rules);
if($validator->fails()){
return response()->json($validator->errors(), 400);
}
$us = Auth::user()->id;
DB::table('sales')->insertGetId(
['date' => $req->query('date'), 'id' => $us, 'earnings' => $req->query('earnings')]);
return view('home',[]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question