This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Schema::table('clicks', function (Blueprint $table) { | |
$table->index('user_id'); | |
$table->index(['user_id', 'date_clicked']); | |
$table->index(['user_id', 'date_clicked', 'ip']); | |
$table->index(['user_id', 'date_clicked', 'country']); | |
$table->index(['user_id', 'date_clicked', 'city']); | |
$table->index(['user_id', 'date_clicked', 'browser']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /your/root/path; | |
index index.html; | |
server_name you.server.com; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Laravel 7.* | |
// Testing jobs: | |
Queue::later(now()->addMinute(), new SomeJob); | |
Queue::assertPushed(SomeJob::class, fn () => ...); // works | |
SomeJob::dispatch()->delay(now()->addMinute()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
OlderNewer