PHP code example of fikrimi / laravel-helper
1. Go to this page and download the library: Download fikrimi/laravel-helper library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fikrimi / laravel-helper example snippets
$first = [
'foo' => 'foo',
'bar' => 'bar',
'foobar' => 'foobar',
'barfoo' => 'barfoo',
];
array_keys_exists(['foo', 'bar'], $first); //true
array_keys_exists(['foo', 'chill'], $first); //false
...
$second = [1, 2, 3, 4, 5];
$third = [
1 => 'isone',
2 => 'istwo',
];
$fourth = [
0 => 'isone',
1 => 'istwo',
];
is_assoc($first); //true
is_assoc($second); //false
is_assoc($third); //true
is_assoc($fourth); //false
dr($param);
...
$param = x;
...
dr($param);
// or ddr($param) to make it die
round_up(10200, 500); // 10500
round_up(910, 900); // 990
round_down(10200, 500); // 10000
round_down(910, 900); // 900
User::select()
->where('id', 5)
->toSql();
// SELECT * FROM `users` where `id` = ?
$user = User::select()
->where('id', 5);
bind_sql($user);
// SELECT * FROM `users` where `id` = 5
$books = \App\Books::select([
'author_id'
])
->selectRaw('COUNT(*) as release_count')
->where('release_date', '>=', '1990-01-01')
->groupBy('author_id');
dd([
\App\Author::select([
'author_id'
])
->selectRaw('COUNT(release_count) as releases')
->join(DB::raw('(' . bind_sql($books) . ') as books'), 'author_id', 'authors.id')
->groupBy('company_id')
->get()
]);
$first = [
'one', 'two', 'three',
];
array_insert_before($first, 1, [
'one and half',
]);
// [
// 'one',
// 'one and half',
// 'two,
// 'three',
// ]