Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Traits\HasScopeWatcher;
class Order extends Model
{
use HasScopeWatcher;
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\Event;
use App\Events\ModelScopeCalled;
use HasScopeAssertion;
abstract class TestCase extends BaseTestCase
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Order;
class OrderControllerTest extends TestCase
{
public function it_returns_paid_and_delivered_orders_sorted_by_created_at_desc(): void
<?php
namespace Tests;
use Illuminate\Support\Facades\Event;
use App\Events\ModelScopeCalled;
trait HasScopeAssertion
{
public function assertScopeCalled(string $scope, string $model)
<?php
namespace App\Http\Controllers;
use App\Models\Order;
use App\Http\Resources\OrderResource;
class OrderController extends Controller
{
public function index()
<?php
namesapce App\Events;
class ModelScopeCalled
{
public function __construct(
public string $scope,
public string $model,
) {
<?php
return [
'hosts' => [
env('ELASTICSEARCH_HOST', 'localhost:9200'),
]
];

Keybase proof

I hereby claim:

  • I am tkaratug on github.
  • I am tkaratug (https://keybase.io/tkaratug) on keybase.
  • I have a public key ASCT2MgDfykk6frZRyOUHvl7LzIfdH31PJ0qmrCwpJzKwwo

To claim this, I am signing this object: