Skip to content

Instantly share code, notes, and snippets.

@Sairahcaz
Created February 2, 2023 12:02
Show Gist options
  • Save Sairahcaz/1a426c0fddfc549775ac800f3a601585 to your computer and use it in GitHub Desktop.
Save Sairahcaz/1a426c0fddfc549775ac800f3a601585 to your computer and use it in GitHub Desktop.
<?php
use LaracraftTech\LaravelUsefulTraits\UsefulScopes;
$class = new class extends Model
{
use UsefulScopes;
protected $timestamps = true;
protected $table = 'scope_tests';
};
$class->create(['foo' => 'foo1', 'bar' => 'bar1', 'quz' => 'quz1']);
$class->create(['foo' => 'foo2', 'bar' => 'bar2', 'quz' => 'quz2', 'created_at' => now()->yesterday()]);
$class::select('foo')->fromToday()->first()->toArray();
// return ['foo' => 'foo1']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment