Category : php

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

In my PHP webapp I use OneDrive login to allow users to read and only read files. I use to URL scope params: files.read.all offline_access in the authorize endpoint call: https://login.microsoftonline.com/common/oauth2/v2.0/authorize My code is based on this source: https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/graph-oauth?view=odsp-graph-online However, during the login process, the OneDrive dialog from Microsoft shows the user that my app ..

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

Here’s my code: $terminosBuscados = ‘Vender la porteria’ $x = $conectarDB->prepare(" SELECT DISTINCT titulo, FROM_UNIXTIME(fecha, ‘%d-%m-%Y’) AS fecha, cuerpo, tipoContenido, autor FROM searchIndex WHERE match(titulo) AGAINST (‘ ? ‘ IN BOOLEAN MODE) ORDER BY contenidoID DESC "); $x->bindParam(1, $terminosBuscados); $x->execute(); $y = $x->fetchAll(PDO::FETCH_ASSOC); This is showing no results at all ($y returns null), when trying ..

Read more