Category : laravel

All the best, I’m a little LOL😂. I am only learning laravel and cannot understand how this code can be optimized $items = DB::table(‘menu_items as i’) ->selectRaw(‘i.*, COUNT(childs.id) as childs_count’) ->leftJoin(‘menu_items as childs’, function($join) { $join->on(DB::raw(‘childs.parent_id’), ‘=’, DB::raw(‘i.id’)) ->whereRaw(‘childs.is_enabled = 1’); }); if($menu_id !== false){ $items->where(‘i.menu_id’, $menu_id); } if ($parent_id !== false){ $items->where(‘i.parent_id’, $parent_id); } ..

Read more

I’m not sure with the title, sorry for that. I have a condition which checks if account is present and if not add the amount to the next account. user-1 – present user-2 – not present user-3 – present user-4 – not present user-5 – present Each user has a corresponding amount to receive, but ..

Read more

I have a problem connecting Laravel to a MySQL database. The project is not inside a docker/homestead virtual box, it’s directly on my PC running Windows 10 (sadly). The .env file looks like that: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=simac DB_USERNAME=root DB_PASSWORD= When I try to run the migrations with artisan migrate I get the following: simacvendorlaravelframeworksrcIlluminateDatabaseConnectorsConnector.php:70 ..

Read more

I have an api call that amongst it has Url’s that are recalled in it’s returned JSON. I need to find those returned urls that have in them the string used for the original get request and have statuses of 200. I tried using the strpos method, but that didn’t seem to work. public function ..

Read more

my controller look like public function react(Request $request){ //echo "hi"; //return; //return response()->json($request); $this->validate($request, [ ‘postid’ => ‘required’, ‘react’ => ‘required’ ]); $reaction = Reaction::firstOrNew([ ‘post_id’=>$request->postid, ‘user_id’=> Auth::id() ]); $reaction->user_id = Auth::id(); $reaction->type = $request->react; $reactType = ""; if ($request->react === "l"){$reactType = "liked";} else if ($request->react === "d"){$reactType = "disliked";} else if ($request->react === ..

Read more

Lumen Version: 8.0.0 PHP Version: 7.4.9 Description: I can’t put cache.Files driver does not work. Boostrap/app.php $app->withFacades(); $app->withEloquent(); $app->configure(‘app’); $app->register(IlluminateRedisRedisServiceProvider::class); $app->configure(‘database’); $app->configure(‘cache’); return $app; Config/Cache.php return [ ‘default’ => env(‘CACHE_DRIVER’, ‘file’), ‘stores’ => [ // … ‘file’ => [ ‘driver’ => ‘file’, ‘path’ => storage_path(‘framework/cache/data’), ], // … ], ‘prefix’ => env( ‘CACHE_PREFIX’, Str::slug(env(‘APP_NAME’, ‘lumen’), ..

Read more