Skip to content

Commit

Permalink
use component v-select
Browse files Browse the repository at this point in the history
  • Loading branch information
cakmalik committed Sep 27, 2022
1 parent 4c4cc6e commit fb6c52d
Show file tree
Hide file tree
Showing 16 changed files with 2,468 additions and 1,937 deletions.
Binary file modified .DS_Store
Binary file not shown.
41 changes: 15 additions & 26 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

namespace App\Http\Controllers\Auth;

use App\Models\User;
use App\Models\Student;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
Expand All @@ -33,7 +29,7 @@ class RegisterController extends Controller
*
* @var string
*/
// protected $redirectTo = RouteServiceProvider::HOME;
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
Expand All @@ -51,11 +47,11 @@ public function __construct()
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(Request $request)
protected function validator(array $data)
{
return Validator::make($request, [
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
Expand All @@ -66,22 +62,15 @@ protected function validator(Request $request)
* @param array $data
* @return \App\Models\User
*/
protected function register(Request $request)
protected function create(array $data)
{
$cek = User::where('email', $request['email']);
if (!$cek->first()) {
$user = User::create([
'name' => $request['name'],
'email' => $request['email'],
'password' => Hash::make($request['password']),
]);
$user->assignRole('tamu');
Auth::loginUsingId($user->id);
return redirect('/home');
} else {
$jumlah_akun = Student::where('user_id', $cek->first()->id)->count();
return inertia('Dashboard/bridge', ['jml_akun' => $jumlah_akun]);
}
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
$user->assignRole('tamu');
return $user;
}

public function showRegistrationForm()
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/StudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class StudentController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function index()
public function biodata()
{
//
$student = Student::where('user_id', Auth::user()->id)->first();
return inertia('Student/Biodata', compact('student'));
}

/**
Expand All @@ -38,9 +39,11 @@ public function create()
*/
public function store(StoreStudentRequest $request)
{
$user = Auth::user();
$data = $request->all();
$data['user_id'] = Auth::user()->id;
$data['user_id'] = $user->id;
Student::create($data);
$user->syncRoles('santri_baru');
sleep(3);
return Redirect::route('home');
}
Expand Down
11 changes: 9 additions & 2 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace App\Http\Middleware;

use Carbon\Carbon;
use Inertia\Middleware;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Http;
use Inertia\Middleware;

class HandleInertiaRequests extends Middleware
{
Expand Down Expand Up @@ -42,9 +43,15 @@ public function share(Request $request): array
$get = 'http://api.aladhan.com/v1/gToH?date=' . $tgl_masehi->format('d-m-Y');
$a = Http::get($get);
$tgl_hijriah = $a['data']['hijri'];
$user = Auth::user();

$role = $user ? $user->roles[0]->name : 'tidak ada';

return array_merge(parent::share($request), [
'tgl_hijriah' => $tgl_hijriah,
'tgl_masehi' => $tgl_masehi->translatedFormat('l, d M Y |')
'tgl_masehi' => $tgl_masehi->translatedFormat('l, d M Y |'),
'user' => $user,
'role' => $role
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/StoreStudentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function rules()
{
return [
'nama' => 'required',
'nik' => 'required',
'nik' => ['required', 'unique:students', 'min:14'],
'jenis_kelamin' => 'required',
'tempat_lahir' => 'required',
'tanggal_lahir' => 'required',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"vue": "^3.2.36",
"vue-loading-button": "^0.2.0",
"vue-loading-overlay": "^5.0.3",
"vue-search-select": "^2.9.5",
"vue-select": "^4.0.0-beta.5",
"vue-step-wizard": "^0.1.17",
"vue3-perfect-scrollbar": "^1.6.0"
}
Expand Down
25 changes: 25 additions & 0 deletions resources/js/Pages/Dashboard/eg-vselect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<v-select
v-model="selected"
:reduce="(option) => option.id"
:options="options"
></v-select>
</template>
<script setup>
import { ref } from "vue";
let selected = ref(3);
let options = ref([
{
id: 1,
label: "One",
},
{
id: 2,
label: "Duaa",
},
{
id: "telu",
label: "3",
},
]);
</script>
30 changes: 30 additions & 0 deletions resources/js/Pages/Dashboard/santri_baru.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<Head><title>Pendaftaran</title></Head>
<AppLayout>
<div
class="alert alert-info border-0 bg-info alert-dismissible fade show py-2"
>
<div class="d-flex align-items-center">
<div class="font-35 text-dark">
<i class="bx bx-info-square"></i>
</div>
<div class="ms-3">
<h6 class="mb-0 text-dark">Info</h6>
<div class="text-dark">
Jangan lupa selesaikan pembayaran administrasi di Pondok
pesantren atau Dengan Virtual Payment
</div>
</div>
</div>
<button
type="button"
class="btn-close"
data-bs-dismiss="alert"
aria-label="Close"
></button>
</div>
</AppLayout>
</template>
<script setup>
import AppLayout from "../../Shared/AppLayout.vue";
</script>
120 changes: 98 additions & 22 deletions resources/js/Pages/Dashboard/tamu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</small>
<BaseInput
v-model="form.nik"
type="text"
type="number"
label="nik"
placeholder="nik"
placeholder="nomer KTP / nomer induk kependudukan "
/>
<BaseInput
v-model="form.nis"
Expand Down Expand Up @@ -118,26 +118,30 @@
label="hobi"
placeholder="hobi"
/>
<BaseInput
v-model="form.cita_cita"
type="text"
label="cita_cita"
placeholder="cita_cita"
/>
<div class="form-group mb-2">
<label class="text-capitalize">Cita-cita</label>
<v-select
v-model="form.cita_cita"
:options="cita"
></v-select>
</div>
</div>
<div class="col-md-6">
<BaseInput
v-model="form.kewarganegaraan"
type="text"
label="kewarganegaraan"
placeholder="kewarganegaraan"
/>
<BaseInput
v-model="form.kebutuhan_khusus"
type="text"
label="kebutuhan_khusus"
placeholder="kebutuhan_khusus"
/>
<div class="form-group mb-2">
<label class="text-capitalize">Kewarganegaraan</label>
<v-select
v-model="form.kewarganegaraan"
:reduce="(kewarganegaraan) => kewarganegaraan.value"
:options="kewarganegaraan"
></v-select>
</div>
<div class="form-group mb-2">
<label class="text-capitalize">Kebutuhan Khusus</label>
<v-select
v-model="form.kebutuhan_khusus"
:options="kebutuhan_khusus"
></v-select>
</div>
<BaseInput
v-model="form.status_rumah"
type="text"
Expand Down Expand Up @@ -255,11 +259,12 @@ import { SelfBuildingSquareSpinner } from "epic-spinners";
import BaseInput from "../../Components/BaseInput.vue";
import { ref, reactive, defineProps } from "vue";
import { Inertia } from "@inertiajs/inertia";
import { ModelSelect } from "vue-search-select";
let isSending = ref(false);
// const firstName = ref("");
// const lastName = ref("");
const form = reactive({
jenis_kelamin: "",
kewarganegaraan: "",
});
const props = defineProps({
Expand All @@ -272,4 +277,75 @@ const handleSubmit2 = () => {
isSending.value = false;
}, 3000);
};
let cita = ref([
"PNS",
"TNI/Polri",
"Guru/Dosen",
"Dokter",
"Politikus",
"Wiraswasta",
"Seniman/Artis",
"Ilmuwan",
"Agamawan",
]);
let kebutuhan_khusus = ref([
"Tidak ada",
"tuna netra",
"tuna rungu",
"tuna daksa",
"tuna grahita",
"tuna laras",
"tuna wicara",
"bakat istimewa",
"kesulitan belajar",
]);
let pendidikan = ref([
"tidak memiliki pendidikan formal",
"sd/mi/sederajat",
"smp/mts/sederajat",
"sma/ma/smk/sederajat",
"d1",
"d2",
"d3",
"d4/s1",
"s2",
"s3",
]);
let pekerjaan = ref([
"tidak bekerja",
"buruh (tani/pabrik/bangunan)",
"dokter/bidan/perawat",
"guru/dosen",
"nelayan",
"pedagang",
"pegawai swasta",
"pengacara/hakim/jaksa/notaris",
"pensiunan",
"petani/peternak",
"pilot/pramugari",
"pns",
"politikus",
"seniman/pelukis/artis/sejenis",
"sopir,masinis,kondektur",
"tni/polisi",
"wiraswasta",
"lainnya",
]);
let penghasilan = ref([
"tidak berpenghasilan",
"kurang dari 500.000",
"500.000 - 1 juta",
"1 juta - 2 juta",
"2 juta - 3 juta",
"3 juta - 4 juta",
"4 juta - 5 juta",
"lebih dari 5 juta",
]);
let hub_wali = ref(["Kakek/nenek", "Paman/bibi", "kakak", "lainnya"]);
let kewarganegaraan = ref([
{ value: "WNI", label: "Warga Negara Indonesia" },
{ value: "WNA", label: "Warga Negara Asing" },
]);
</script>
Loading

0 comments on commit fb6c52d

Please sign in to comment.