Category : backend

I want to pass some parameters to an after middleware after the controller has finished running, this is in order to invalidate any password reset tokens if a new one is generated. My code is: Controller public function resetPasswordRequest(Request $request) { $user = User::where(’email’, $request->email)->first(); if (!$user) { throw ValidationException::withMessages([ ‘message’ => ‘invalid_email’, ]); } ..

Read more

Let’s say we have a helper function, logDatabaseError($exception) that logs QueryExceptions to a special log. helpers.php function logDatabaseError ($exception) { $controller = ????; $function = ????; $log_string = "TIME: ".now().PHP_EOL; $log_string.= "User ID: ".Auth::user()->id.PHP_EOL; $log_string.= "Controller->Action:".$controller."->".$function.PHP_EOL; $log_string.= $exception.PHP_EOL; Storage::disk(‘logs’)->append(‘database.log’, $log_string); } This function is called from multiple controllers and multiple functions within those controllers. Whenever ..

Read more

Let’s say we have a helper function, logDatabaseError($exception) that logs QueryExceptions to a special log. helpers.php function logDatabaseError ($exception) { $controller = ????; $function = ????; $log_string = "TIME: ".now().PHP_EOL; $log_string.= "User ID: ".Auth::user()->id.PHP_EOL; $log_string.= "Controller->Action:".$controller."->".$function.PHP_EOL; $log_string.= $exception.PHP_EOL; Storage::disk(‘logs’)->append(‘database.log’, $log_string); } This function is called from multiple controllers and multiple functions within those controllers. Whenever ..

Read more

I’m doing full stuck development using Angular12 as Front End and Laravel as BackEnd. I want to do a search using multiple values but I don’t have any idea. I could search using a single value but I want to do with multiple values(AND oparation). LARAVEL api.php Route::get(‘/project/search/{request}’, [ProjectController::class, ‘search’]); ProjectController.php { if ($request===’business_divition’){ return ..

Read more

I created a new Laravel project and downloaded the bootstrap CSS and JS files and put the CSS file in resources/css and the JS files of bootstrap and popper and jQuery in resources/js and in the welcome.blade.php I linked the CSS file and the JS files like this <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> ..

Read more

I changed XAMPP configuration ports and localhost, when I ran old project it doesn’t work so I need anyone to help me to match the .env with XAMPP configuration the XAMPP window Apache Service Window MySQL Service Window the .env file APP_NAME=Laravel APP_ENV=local APP_KEY=base64:kuAaczKFkzJWGNlZzrPpsBsmv+NNMCMPVwTsNYsbZyc= APP_DEBUG=true APP_URL=http://localhost LOG_CHANNEL=stack LOG_LEVEL=debug DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=mobitech DB_USERNAME=root DB_PASSWORD= BROADCAST_DRIVER=log ..

Read more

Trying to sort assets based on price. blade.php <form action="/assets/search/" method="GET" class="form-inline"> @csrf <div class="searchByPrice pt-3"> <p class="font-weight-bold">Search By Price</p> <label for="price">Volume</label> <input type="range" min="0" max="500000" id="price" step="100" name="price" oninput="outputUpdate(value)"> <output for="price" id="volume">250000</output> <script> function outputUpdate(vol) { document.querySelector(‘#volume’).value = vol; } </script> </div> </form> Controller public function show(Request $request, $_id) { $query = Asset::query(); if ..

Read more

I am new to Laravel, I want to display the menu for each restaurant from the database, the list of Restaurants is in the home section and each restaurant must have a different menu web.php: Route::get("/Menu/", [HomeController::class, "menu"]); HomeController: public function menu() { $data=DB::table(‘restaurants_menu’) ->select(‘*’) ->get(‘*’); return view(‘restaurant_menu’,compact(‘data’)); } restaurant_menu.blade.php : <div class="menu-container"> @foreach($data as ..

Read more

Getting this error after updating the image. Call to a member function getClientOriginalExtension() on string This is the before code. If I dd(); this code I get the file name with the extension but it’s a string. So I cannot get the original extension. $image = $request->warrantyUpload; $destination = public_path(‘/uploads/’); $ext = $image->getClientOriginalExtension(); $mainFilename = ..

Read more

Good morning developers, iam working on ecommerce project using laravel and angular in laravel i made two tables ( brands – products ) and i need the brand has many products so i added this function to the Product model public function brand() { return $this->belongsTo(Brand::class); } and i added this function to Brand model ..

Read more