119 lines
2.8 KiB
PHP
119 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Anggota;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class RegisterController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('auth.register');
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create(Request $request)
|
|
{
|
|
$request->validate([
|
|
'name' => 'required',
|
|
'email' => 'required|email|unique:users,email',
|
|
'alamat' => 'required',
|
|
'password' => 'required|min:6',
|
|
'no_handpone' => 'required',
|
|
], [
|
|
'name.required' => 'Nama tidak boleh kosong',
|
|
'email.required' => 'Email tidak boleh kosong',
|
|
'email.email' => 'Email tidak valid',
|
|
'email.unique' => 'Email sudah terdaftar',
|
|
'alamat.required' => 'Alamat tidak boleh kosong',
|
|
'password.required' => 'Password tidak boleh kosong',
|
|
'password.min' => 'Password minimal 6 karakter',
|
|
'no_handpone.required' => 'No Handpone tidak boleh kosong',
|
|
|
|
]);
|
|
|
|
$user = new User();
|
|
$user->name = $request->name;
|
|
$user->email = $request->email;
|
|
$user->alamat = $request->alamat;
|
|
$user->password = Hash::make($request->password);
|
|
$user->no_handpone = $request->no_handpone;
|
|
$user->save();
|
|
|
|
$anggota = new Anggota();
|
|
$anggota->users_id = $user->id;
|
|
$anggota->save();
|
|
|
|
return redirect('/login')->with('register', 'Register Berhasil, Silahkan Login');
|
|
}
|
|
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show($id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update(Request $request, $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param int $id
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
//
|
|
}
|
|
}
|