Compare commits
No commits in common. "d106ba956acb5738f4fa56671b2c3fb09925a84e" and "837a1ffa5b30a6bcd90d2266a23c2029a56ce406" have entirely different histories.
d106ba956a
...
837a1ffa5b
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Hash;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Validator;
|
|
||||||
|
|
||||||
class PublicUserController extends Controller
|
|
||||||
{
|
|
||||||
public function register(Request $request)
|
|
||||||
{
|
|
||||||
$data = $request->all()['user'];
|
|
||||||
if (User::where([ 'email' => $data['email'] ])->count() != 0) {
|
|
||||||
return response('email_taken', 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
$user = User::create([
|
|
||||||
...$data,
|
|
||||||
'password' => Hash::make($request->input('password'))
|
|
||||||
]);
|
|
||||||
$user->save();
|
|
||||||
session('user', $user->id);
|
|
||||||
session()->save();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,15 +3,13 @@
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use App\UuidId;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Infocyph\UID\UUID;
|
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
use HasFactory, Notifiable, UuidId;
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
|
@ -23,8 +21,6 @@ class User extends Authenticatable
|
||||||
'name',
|
'name',
|
||||||
'middle_name',
|
'middle_name',
|
||||||
'email',
|
'email',
|
||||||
'phone',
|
|
||||||
'password',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
use Ramsey\Uuid\Uuid;
|
|
||||||
|
|
||||||
trait UuidId
|
|
||||||
{
|
|
||||||
protected static function boot() {
|
|
||||||
parent::boot();
|
|
||||||
static::creating(function ($model) {
|
|
||||||
$model->id = Uuid::uuid6()->toString();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public function getIncrementing(): bool {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public function getKeyType(): string {
|
|
||||||
return 'string';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,6 @@ return new class extends Migration
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('middle_name');
|
$table->string('middle_name');
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->string('phone');
|
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Http\Controllers\PublicUserController;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('/api')->group(function() {
|
|
||||||
Route::controller(PublicUserController::class)->prefix('/users')->group(function() {
|
|
||||||
Route::put('/register', 'register');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/session', function() {
|
|
||||||
exit(print_r(session()->all(), true));
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue