Block staff id from register

This commit is contained in:
Amir
2022-12-14 07:07:43 +08:00
parent 42d21b6324
commit 193a440daf
2 changed files with 30 additions and 2 deletions
@@ -7,6 +7,7 @@ use Carbon\Carbon;
use App\Models\User;
use App\Models\File;
use App\Http\Controllers\Controller;
use App\Models\Staff;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
@@ -25,8 +26,6 @@ class AuthController extends Controller
'register_agree' => 'required|integer',
'alamat' => 'required'
]);
if ($validator->fails()) {
$errors = [
@@ -37,6 +36,18 @@ class AuthController extends Controller
}
// Retrieve the validated input...
$fields = $validator->validated();
$convert_ic_to_hyphen = (substr_replace(substr_replace($fields['nokp'], '-', 6, 0), '-', 9, 0));
$check_staff = Staff::where('nokp', '=', $convert_ic_to_hyphen)->first();
if($check_staff)
{
$errors = [
'success' => "Staff",
'message' => "Staff tidak dibenarkan mendaftar."
];
return response($errors, 201);
}
$currentdate = Carbon::now();
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Staff extends Model
{
use HasFactory;
protected $table = 'staffs';
protected $fillable = [
];
}