<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
luilliarcec / laravel-username-generator example snippets
use Illuminate\Database\Eloquent\Model;
use Luilliarcec\LaravelUsernameGenerator\Concerns\HasUsername;
class User extends Model
{
use HasUsername;
}
protected function getUsernameColumn(): string
{
return 'my_username_column';
}
protected function getName(): string
{
// This is the value, not the field name.
return $this->name;
}
protected function getLastName(): ?string
{
// This is the value, not the field name.
return $this->last_name;
}
use Luilliarcec\LaravelUsernameGenerator\Drivers\Email;
protected function getUsernameDriver(): DriverContract
{
return new Email();
}
protected function transformUsername(string $username): string
{
return mb_strtoupper($username, 'UTF-8');
}
namespace App\Support\Username\Drivers;
use Luilliarcec\LaravelUsernameGenerator\Contracts\DriverContract;
class CustomDriver implements DriverContract
{
public function make(string $name, string $lastname = null): string
{
// your code
}
}