store function not recognizing field Very new and I can't figure out a very basic thing. How would I add the value of Auth::user()->id to a user_id field when it's not passed through the form?
public function store()
{
Auth::user()->sfa->student_meals()->create(
Request::validate([
'date_served' => ['required'],
'meal_type_id' => ['nullable', Rule::exists('meal_types', 'id')],
'tally' => ['required'],
]),
);
return Redirect::route('studentMeals')->with('success', 'Meal added.');
@mkainaroi
create(
array_merge(
Request::validate([
'date_served' => ['required'],
'meal_type_id' => ['nullable', Rule::exists('meal_types', 'id')],
'tally' => ['required'],
]),
['user_id' => auth()->id()]
)
)
Please sign in or create an account to participate in this conversation.