skip to Main Content

How to pass data to AppServiceProvider? – Laravel

I'm trying to pass the $product variable in this controller to multiple view files. function show($lang, $slug) { $product = Product::where('slug', $slug)->firstOrFail(); $mightAlsoLike = Product::where('slug', '!=', $slug)->MightAlsoLike()->get(); return view('shop_show')->with(['product' => $product, 'mightAlsoLike' => $mightAlsoLike]); } I'm using view composer in…

VIEW QUESTION

How to make default request values inside $validated array in Laravel?

Controller code: public function store(UserStoreRequest $request) { $validated = $request->validated(); $validated['user_type_id'] = 2; $validated['user_gender_id'] = $request->user_gender_id; $validated['last_login_at'] = Carbon::now(); $validated['password'] = Hash::make($request->password); User::create($validated); return to_route('all-users'); } Is there a better way to do this? I tried something like this but…

VIEW QUESTION
Back To Top
Search