Oftently or occasionally way of using site_url and base_url variable
1. site_url
when including inside of "application" folder dealing with accessing view and controllers in codeigniter
2. base_url
when to include assets like js, css and images file from root project folder
Thursday, 2 August 2018
Visual Code (Goto Definition) using Php IntelliSense
files > preferences > settings
In user settings :
In user settings :
{
"php.validate.executablePath": "C:\\wamp64\\bin\\php\\php7.2.4\\php.exe",
"php.executablePath": "C:\\wamp64\\bin\\php\\php7.2.4\\php.exe"
}
Friday, 13 July 2018
array_push() merging multiple array
That's because you're adding a non-object to the last element of the array.
Here i suppose you get an array of objects with the name property
$competition_all = Competition::all();
Here you add a key=>value pair to the last element of the objects array
$newCompete = array('name'=>'Others');
array_push($competition_all, $newCompete);
Here you walk through the array of objects and when it comes to the last element the "$competition_games->name" has no name property
foreach ($competition_all as $competition_games) {
$this->competition_games[$competition_games->name] = $competition_games->name;
}
Try something like including a stdclass for it like :
$newCompete = new StdClass();
$newCompete->name = 'Others';
array_push($competition_all, $newCompete);
Merging into New Laravel Collection
resources :
https://stackoverflow.com/questions/23599584/how-to-manually-create-a-new-empty-eloquent-collection-in-laravel-4
Wednesday, 11 July 2018
Interview Training
connect mysql from cli :
cd "C:\wamp64\bin\mysql\mysql5.7.21\bin"
C:\wamp64\bin\mysql\mysql5.7.21\bin > mysql.exe -u root
Microsoft .Net utilities :
1. Entity Framework
2. LinQ .(Net Integrated Query)
cd "C:\wamp64\bin\mysql\mysql5.7.21\bin"
C:\wamp64\bin\mysql\mysql5.7.21\bin > mysql.exe -u root
Microsoft .Net utilities :
1. Entity Framework
2. LinQ .(Net Integrated Query)
Wednesday, 4 July 2018
Thursday, 14 June 2018
Check if empty in collection
When using
->get() you cannot simply use any of the below:if (empty($result)) { }
if (!$result) { }
if ($result) { }
Because if you
dd($result); you'll notice an instance of Illuminate\Support\Collection is always returned, even when there are no results. Essentially what you're checking is $a = new stdClass; if ($a) { ... } which will always return true.
To determine if there are any results you can do any of the following:
if ($result->first()) { }
if (!$result->isEmpty()) { }
if ($result->count()) { }
if (count($result)) { }
Subscribe to:
Posts (Atom)