-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMahasiswaController.php
54 lines (44 loc) · 1.13 KB
/
MahasiswaController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use App\Mahasiswa;
class MahasiswaController extends Controller
{
public function loginMhs()
{
return view('mahasiswa.login');
}
public function prosesLogin(Request $req)
{
$credential = $req->only('email','password');
return (String)Auth::guard('mhs')->attempt($credential);
}
public function register()
{
return view('mahasiswa.register');
}
public function prosesRegister(Request $req)
{
$save = Mahasiswa::create([
'nama' => $req->nama,
'email' => $req->email,
'password' => Hash::make($req->password),
]);
$status = ['status' => 'Failed'];
if($save)
$status = ['status' => 'Success'];
return redirect('registermhs')->with($status);
}
public function status()
{
return (String)Auth::guard('mhs')->user();
}
public function logout()
{
Auth::guard('mhs')->logout();
return 'hola';
}
}