Skip to content

Instantly share code, notes, and snippets.

@raksit31667
Created May 2, 2024 17:35
Show Gist options
  • Save raksit31667/265e832d329931c2ec0604151c6e6c6b to your computer and use it in GitHub Desktop.
Save raksit31667/265e832d329931c2ec0604151c6e6c6b to your computer and use it in GitHub Desktop.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
...
public static function findByName(string $name)
{
return self::with('accounts')->where('name', $name)->first();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment