ASSUMING YOU HAVE DOCKER INSTALLED ON YOUR PLATFORM
https://docs.docker.com/engine/installation/
- In the project root create
.dockerfolder anddocker-compose.ymlfile - contents below - Create
.docker/site.conffile with nginx setup - contents below
| <?php // ~/.config/psysh/config.php | |
| // Anything not Laravel - let's try to autoload something likely to exist | |
| if (!defined('LARAVEL_START')) { | |
| return [ | |
| 'defaultIncludes' => [ | |
| getcwd().'/vendor/autoload.php', | |
| getcwd().'/bootstrap/autoload.php', | |
| ], | |
| ]; |
| <?php | |
| // Freek posted a query today, that drives OhDearApp filters (the app recommended!): | |
| // @link https://twitter.com/freekmurze/status/972299131497713664 | |
| // We can make the query more eloquent, so why don't we use a scope! | |
| // I | |
| // Let's make it really eloquent and get here: | |
| $site->downtimePeriods() |
ASSUMING YOU HAVE DOCKER INSTALLED ON YOUR PLATFORM
https://docs.docker.com/engine/installation/
.docker folder and docker-compose.yml file - contents below.docker/site.conf file with nginx setup - contents below| <?php | |
| // meh | |
| $mock | |
| ->method('sum') | |
| ->withConsecutive([1,2,3], [4,5,6]) | |
| ->willReturnOnConsecutiveCalls(6, 15); | |
| // instead? | |
| $mock->method('sum')->with(1,2,3)->willReturn(6); |
| <?php | |
| // Laravel 7.* | |
| // Testing jobs: | |
| Queue::later(now()->addMinute(), new SomeJob); | |
| Queue::assertPushed(SomeJob::class, fn () => ...); // works | |
| SomeJob::dispatch()->delay(now()->addMinute()); |
| <?php | |
| >>> $col = collect(json_decode(json_encode([['id' => 1,'bool' => 0, 'count' => 15], ['id' => 2, 'bool' => 1, 'count' => 20], ['id' => 3, 'bool' => 0, 'count' => 10], ['id' => 4, 'bool' => 1, 'count' => 16]]))) | |
| => Illuminate\Support\Collection {#935 | |
| all: [ | |
| {#936 | |
| +"id": 1 | |
| +"bool": 0 | |
| +"count": 15 | |
| } |
| <?php | |
| // given input ['name' => 'jarek'] | |
| Request::only('name', 'email') | |
| [ | |
| "name" => "jarek", | |
| "email" => null, // even if empty in the input, the key will be here | |
| ] | |
| <?php | |
| // Not exactly one-liner but.. ;) | |
| // -------------------- | |
| // require: | |
| // illuminate/support | |
| // guzzlehttp/guzzle | |
| $user = 'jarektkaczyk'; | |
| $stars = collect(json_decode((new Guzzlehttp\Client)->get("https://api.github.com/users/{$user}/repos")->getBody(), true)) |
| <?php | |
| // Add this override to your app/Exceptions/Handler.php | |
| /** | |
| * Render an exception to the console. | |
| * | |
| * @param \Symfony\Component\Console\Output\OutputInterface $output | |
| * @param \Exception $e | |
| * @return void |
| <?php | |
| $this->builder | |
| ->select('*') // needs to be here, otherwise the only returned column will be `last_login` | |
| ->selectSub(function ($q) { | |
| $q->from('action_logs') | |
| ->whereColumn('user_id', 'users.id') | |
| ->selectRaw('max(created_at)'); | |
| }, 'last_login') | |
| ->get(); |