main
ilhamwara 2025-02-11 14:19:34 +07:00
parent 235908fdcc
commit b10863941e
17 changed files with 483 additions and 23 deletions

View File

@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
use App\Models\User;
use App\Models\ProfileSekolah as Profile;
class CustomRegisterController extends Controller
{
@ -19,8 +20,9 @@ class CustomRegisterController extends Controller
public function post_register(Request $request)
{
Validator::make($request->all(), [
'email' => 'required|unique:user|email|regex:/@.*\./',
try {
Validator::make($request->all(), [
'email' => 'required|unique:users|email',
'name' => 'required|max:50',
'npsn' => 'required',
'tingkat_sekolah' => 'required',
@ -30,6 +32,47 @@ class CustomRegisterController extends Controller
'telp' => 'required',
'check' => 'required',
'password' => 'required|min:8|max:15|regex:/[a-z]/|regex:/[A-Z]/|regex:/[0-9]/|regex:/[@$!%*#?&]/', //min 8 char, maks 15 char, min 1 symbol, min 1 uppercase, min 1 lowercase, 1 number
],[
'password.min' => 'password Minimal 8 Karakter',
'password.max' => 'password Maksimal 15 Karakter',
'password.regex' => 'Format Kata Sandi harus mengandung minimal Huruf Besar, Huruf Kecil, Angka, Spesial Karakter',
])->validate();
$cek = Profile::where('npsn',$request->npsn)->count();
if($cek > 0){
return redirect('register')->with([
'message' => 'Untuk NPSN :'.$request->npsn.' Sudah terdaftar! Silahkan Login',
'type' => "error"
]);
}
$user = new User;
$user->email = $request->email;
$user->password = Hash::make($request->password);
$user->name = $request->name;
$user->save();
$profile = new Profile;
$profile->user_id = $user->id;
$profile->npsn = $request->npsn;
$profile->ms_tingkat_sekolah_id = $request->tingkat_sekolah;
$profile->status_sekolah = $request->status_sekolah;
$profile->alamat_sekolah = $request->alamat_sekolah;
$profile->kontak_person = $request->kontak_person;
$profile->telp = $request->telp;
$profile->save();
return redirect('/login')->with([
'message' => 'Berhasil membuat akun baru, silahkan login',
'type' => 'success',
]);
} catch (Exception $e) {
return redirect('register')->with([
'message' => $e->getMessage(),
'type' => "error"
]);
}
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MasterAccessMenu extends Model
{
use HasFactory;
protected $table = 'ms_access_menu';
protected $primaryKey = 'MsAccessMenuId';
protected $fillable = [
'ms_group_id',
'module',
'ms_menu_id',
'menu_group',
'is_create',
'is_read',
'is_update',
'is_delete',
'is_verify',
'is_approve',
'is_download',
'access',
];
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MasterGroup extends Model
{
use HasFactory;
protected $table = 'ms_group';
protected $primaryKey = 'MsGroupId';
protected $fillable = [
'menu_group',
'menu_group_alias',
'status',
'created_by',
'updated_by',
];
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MasterGroupUser extends Model
{
use HasFactory;
protected $table = 'ms_group_user';
protected $primaryKey = 'MsGroupUserId';
protected $fillable = [
'ms_group_id',
'user_id',
]
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MasterMenu extends Model
{
use HasFactory;
protected $table = 'ms_menu';
protected $primaryKey = 'MsMenuId';
protected $fillable = [
'parent_id',
'title',
'module',
'url',
'menu_type',
'menu_icons',
'ordering',
'status',
'created_by',
'updated_by',
];
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class MasterTingkatSekolah extends Model
{
use SoftDeletes;
use HasFactory;
protected $table = 'ms_tingkat_sekolah';
protected $primaryKey = 'MsTingkatSekolahId';
protected $fillable = [
'name',
];
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class ProfileSekolah extends Model
{
use HasFactory;
protected $table = 'profile';
protected $primaryKey = 'ProfileId';
protected $fillable = [
'user_id',
'npsn',
'ms_tingkat_sekolah_id',
'status_sekolah',
'alamat_sekolah',
'kontak_person',
'telp',
];
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('profile', function (Blueprint $table) {
$table->id('ProfileId');
$table->string('npsn')->nullable();
$table->integer('ms_tingkat_sekolah_id')->default(0);
$table->string('status_sekolah')->nullable();
$table->text('alamat_sekolah')->nullable();
$table->string('kontak_person')->nullable();
$table->string('telp')->nullable();
$table->timestampsTz();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('profile_sekolahs');
}
};

View File

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_tingkat_sekolah', function (Blueprint $table) {
$table->id('MsTingkatSekolahId');
$table->string('name')->nullable();
$table->timestampsTz();
$table->softDeletesTz();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_tingkat_sekolahs');
}
};

View File

@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('profile', function (Blueprint $table) {
$table->foreign('ms_tingkat_sekolah_id')->references('MsTingkatSekolahId')->on('ms_tingkat_sekolah')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('profile', function (Blueprint $table) {
$table->integer('user_id')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('profile', function (Blueprint $table) {
//
});
}
};

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_menu', function (Blueprint $table) {
$table->id('MsMenuId');
$table->foreignId('parent_id')->index()->default(0)->comment('idx menu_id');
$table->string('title', 150);
$table->string('module', 150)->nullable();
$table->string('url', 150)->nullable();
$table->string('menu_type', 50)->index()->nullable()->comment('tb_menu_group alias');
$table->string('menu_icons', 50)->nullable();
$table->tinyInteger('ordering')->default(0);
$table->boolean('status')->default(true)->comment('True/False');
$table->foreignId('created_by')->default(0);
$table->foreignId('updated_by')->default(0)->nullable();
$table->timestamps();
$table->comment('Master menu aplikasi');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_menus');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_group', function (Blueprint $table) {
$table->id('MsGroupId');
$table->string('menu_group', 50)->unique();
$table->string('menu_group_alias', 50)->unique();
$table->boolean('status')->default(true)->comment('True/False');
$table->foreignId('created_by')->default(0);
$table->foreignId('updated_by')->default(0)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_groups');
}
};

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_access_menu', function (Blueprint $table) {
$table->id('MsAccessMenuId');
$table->foreignId('ms_group_id')->comment('FK ms group');
$table->string('module', 150)->nullable();
$table->foreignId('ms_menu_id')->comment('FK tb_menu');
$table->string('menu_group', 20)->nullable()->default('adminsidebar');
$table->boolean('is_create')->default(false);
$table->boolean('is_read')->default(false);
$table->boolean('is_update')->default(false);
$table->boolean('is_delete')->default(false);
$table->boolean('is_verify')->default(false);
$table->boolean('is_approve')->default(false);
$table->boolean('is_download')->default(false);
$table->json('access')->nullable();
$table->timestamps();
$table->foreign('ms_menu_id')->references('MsMenuId')->on('ms_menu')->cascadeOnDelete();
$table->foreign('ms_group_id')->references('MsGroupId')->on('ms_group')->cascadeOnDelete();
$table->comment('Master hak akses role/group user');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_access_menus');
}
};

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_group_user', function (Blueprint $table) {
$table->id('MsGroupUserId');
$table->foreignId('ms_group_id')->comment('FK Group');
$table->foreignId('user_id')->comment('FK User');
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
$table->foreign('ms_group_id')->references('MsGroupId')->on('ms_group')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_group_users');
}
};

View File

@ -4,6 +4,8 @@ namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Master\MasterTingkatSekolah;
use Hash;
class DatabaseSeeder extends Seeder
@ -13,16 +15,35 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
\DB::table('users')->insert([
User::updateOrCreate([
'name' => 'Administrator',
'email' => 'adminadiwiyata@dlh.go.id',
],[
'name' => 'Administrator',
'email' => 'adminadiwiyata@dlh.go.id',
'password' => Hash::make('##SekolahAdiwiyata123'),
]);
// \App\Models\User::factory(10)->create();
// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => 'test@example.com',
// ]);
$data = [
['name' => 'SD'],
['name' => 'SMP'],
['name' => 'SMA'],
['name' => 'SMK'],
['name' => 'MI'],
['name' => 'MTs'],
['name' => 'MA'],
['name' => 'SD LB'],
['name' => 'SMP LB'],
['name' => 'SMA LM'],
['name' => 'SLB Khusus'],
];
foreach($data as $val){
MasterTingkatSekolah::updateOrCreate([
'name' => $val['name'],
],[
'name' => $val['name'],
]);
}
}
}

View File

@ -49,9 +49,9 @@
<div class="form-group row">
<label class="col-xl-12 form-label" for="fname">NPSN</label>
<div class="col-12 pr-1">
<input maxlength="8" type="text" name="npsn" class="form-control @error('npsn') is-invalid @enderror numberInput" placeholder="Masukan NPSN Sekolah" required>
<input maxlength="8" type="text" value="{{old('npsn')}}" name="npsn" class="form-control @error('npsn') is-invalid @enderror numberInput" placeholder="Masukan NPSN Sekolah" required>
@error('npsn')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
<small class="text-primary"><i>Pastikan NPSN Telah Sesuai</i></small>
</div>
@ -60,9 +60,9 @@
<div class="form-group row">
<label class="col-xl-12 form-label" for="fname">Nama Sekolah</label>
<div class="col-12 pr-1">
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror" placeholder="Masukan Nama Sekolah" required>
<input type="text" value="{{old('name')}}" name="name" class="form-control @error('name') is-invalid @enderror" placeholder="Masukan Nama Sekolah" required>
@error('name')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
</div>
@ -84,7 +84,7 @@
<option value="11" data-select2-id="21">SLB Khusus</option>
</select>
@error('tingkat_sekolah')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
</div>
@ -97,36 +97,36 @@
<option value="Swasta">Swasta</option>
</select>
@error('status_sekolah')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
</div>
<div class="form-group">
<label class="form-label" for="emailverify">Alamat Sekolah</label>
<input type="text" name="alamat_sekolah" class="form-control @error('alamat_sekolah') is-invalid @enderror" placeholder="Masukan Alamat Sekolah, Nama Jalan / Dusun / RT-RW" required>
<input type="text" value="{{old('alamat_sekolah')}}" name="alamat_sekolah" class="form-control @error('alamat_sekolah') is-invalid @enderror" placeholder="Masukan Alamat Sekolah, Nama Jalan / Dusun / RT-RW" required>
@error('alamat_sekolah')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
<div class="form-group">
<label class="form-label" for="emailverify">Kontak Person</label>
<input type="text" name="kontak_person" class="form-control @error('kontak_person') is-invalid @enderror" placeholder="Masukan Kontak Person" required>
<input type="text" value="{{old('kontak_person')}}" name="kontak_person" class="form-control @error('kontak_person') is-invalid @enderror" placeholder="Masukan Kontak Person" required>
@error('kontak_person')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
<div class="form-group">
<label class="form-label" for="emailverify">Telp/WA</label>
<input type="text" name="telp" class="form-control @error('telp') is-invalid @enderror numberInput" maxlength="16" placeholder="Masukan Telp/WA" required>
<input type="text" value="{{old('telp')}}" name="telp" class="form-control @error('telp') is-invalid @enderror numberInput" maxlength="16" placeholder="Masukan Telp/WA" required>
@error('telp')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
<div class="form-group">
<label class="form-label" for="emailverify">Email</label>
<input type="email" name="email" id="emailverify" class="form-control @error('email') is-invalid @enderror" placeholder="Masukan Email Aktif" required>
@error('email')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
<small class="text-primary">* Pastikan email benar dan aktif, akses aplikasi akan dikirim ke email yang didaftarkan.</small>
</div>
@ -139,16 +139,17 @@
</div>
</div>
@error('password')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
<div class="help-block">
Kata Sandi harus mengandung Minimal 8 karakter, maksimal 15 karakter, <br>setidaknya 1 huruf kecil dan huruf besar, angka dan simbol
</div>
</div>
<div class="form-group">
<input type="checkbox" name="check" required> Dengan ini menyatakan bahwa isian registrasi diatas sudah benar.
@error('check')
<span class="invalid-feedback"><strong>{{$message}}</strong></span>
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror
</div>
<div class="row no-gutters">