This commit is contained in:
Azfar Arsyad
2022-01-17 16:24:52 +08:00
parent 4dff8131e4
commit 3c20c03ab9
3 changed files with 49 additions and 2 deletions
@@ -19,13 +19,17 @@ class AuthController extends Controller
'username' => 'required|string|unique:users',
'nokp' => 'required|string|unique:users',
'password' => 'required|string|min:8',
'notelbimbit' => 'required|string',
'notelbimbit' => 'required|string|unique:users',
'register_agree' => 'required|integer'
]);
$errors = [
'success' => "error",
'message' => $validator->errors()
];
if ($validator->fails()) {
return response($validator->errors(), 201);
return response($errors, 201);
}
// Retrieve the validated input...
$fields = $validator->validated();
@@ -58,6 +62,7 @@ class AuthController extends Controller
$token = $user->createToken('myapptoken')->plainTextToken;
$response = [
'success' => "success",
'user' => $user,
'token' => $token
];
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Cart extends Model
{
use HasFactory;
}
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCartsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('carts', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('carts');
}
}