Skip to content

Commit 187564e

Browse files
committed
Finished Part #1
1 parent 9120686 commit 187564e

File tree

13 files changed

+532
-1
lines changed

13 files changed

+532
-1
lines changed

app/Admin.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Notifications\Notifiable;
6+
use Illuminate\Foundation\Auth\User as Authenticatable;
7+
8+
class Admin extends Authenticatable
9+
{
10+
use Notifiable;
11+
12+
protected $guard = 'admin';
13+
14+
/**
15+
* The attributes that are mass assignable.
16+
*
17+
* @var array
18+
*/
19+
protected $fillable = [
20+
'name', 'email', 'password', 'job_title',
21+
];
22+
23+
/**
24+
* The attributes that should be hidden for arrays.
25+
*
26+
* @var array
27+
*/
28+
protected $hidden = [
29+
'password', 'remember_token',
30+
];
31+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class AdminController extends Controller
8+
{
9+
/**
10+
* Create a new controller instance.
11+
*
12+
* @return void
13+
*/
14+
public function __construct()
15+
{
16+
$this->middleware('auth:admin');
17+
}
18+
19+
/**
20+
* Show the application dashboard.
21+
*
22+
* @return \Illuminate\Http\Response
23+
*/
24+
public function index()
25+
{
26+
return view('admin');
27+
}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class HomeController extends Controller
8+
{
9+
/**
10+
* Create a new controller instance.
11+
*
12+
* @return void
13+
*/
14+
public function __construct()
15+
{
16+
$this->middleware('auth');
17+
}
18+
19+
/**
20+
* Show the application dashboard.
21+
*
22+
* @return \Illuminate\Http\Response
23+
*/
24+
public function index()
25+
{
26+
return view('home');
27+
}
28+
}

config/auth.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@
4545
'driver' => 'token',
4646
'provider' => 'users',
4747
],
48+
'admin' => [
49+
'driver' => 'session',
50+
'provider' => 'admins',
51+
],
52+
'admin-api' => [
53+
'driver' => 'token',
54+
'provider' => 'admins',
55+
],
4856
],
4957

5058
/*
@@ -69,6 +77,10 @@
6977
'driver' => 'eloquent',
7078
'model' => App\User::class,
7179
],
80+
'admins' => [
81+
'driver' => 'eloquent',
82+
'model' => App\Admin::class,
83+
],
7284

7385
// 'users' => [
7486
// 'driver' => 'database',
@@ -97,6 +109,10 @@
97109
'table' => 'password_resets',
98110
'expire' => 60,
99111
],
112+
'admins' => [
113+
'provider' => 'admins',
114+
'table' => 'password_resets',
115+
'expire' => 15,
116+
],
100117
],
101-
102118
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateAdminsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('admins', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->string('name');
19+
$table->string('email')->unique();
20+
$table->string('job_title');
21+
$table->string('password');
22+
$table->rememberToken();
23+
$table->timestamps();
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down()
33+
{
34+
Schema::dropIfExists('admins');
35+
}
36+
}

resources/views/admin.blade.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@extends('layouts.app')
2+
3+
@section('content')
4+
<div class="container">
5+
<div class="row">
6+
<div class="col-md-8 col-md-offset-2">
7+
<div class="panel panel-default">
8+
<div class="panel-heading">ADMIN Dashboard</div>
9+
10+
<div class="panel-body">
11+
You are logged in as <strong>ADMIN</strong>
12+
</div>
13+
</div>
14+
</div>
15+
</div>
16+
</div>
17+
@endsection

resources/views/auth/login.blade.php

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@extends('layouts.app')
2+
3+
@section('content')
4+
<div class="container">
5+
<div class="row">
6+
<div class="col-md-8 col-md-offset-2">
7+
<div class="panel panel-default">
8+
<div class="panel-heading">Login</div>
9+
<div class="panel-body">
10+
<form class="form-horizontal" role="form" method="POST" action="{{ route('login') }}">
11+
{{ csrf_field() }}
12+
13+
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
14+
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
15+
16+
<div class="col-md-6">
17+
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>
18+
19+
@if ($errors->has('email'))
20+
<span class="help-block">
21+
<strong>{{ $errors->first('email') }}</strong>
22+
</span>
23+
@endif
24+
</div>
25+
</div>
26+
27+
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
28+
<label for="password" class="col-md-4 control-label">Password</label>
29+
30+
<div class="col-md-6">
31+
<input id="password" type="password" class="form-control" name="password" required>
32+
33+
@if ($errors->has('password'))
34+
<span class="help-block">
35+
<strong>{{ $errors->first('password') }}</strong>
36+
</span>
37+
@endif
38+
</div>
39+
</div>
40+
41+
<div class="form-group">
42+
<div class="col-md-6 col-md-offset-4">
43+
<div class="checkbox">
44+
<label>
45+
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
46+
</label>
47+
</div>
48+
</div>
49+
</div>
50+
51+
<div class="form-group">
52+
<div class="col-md-8 col-md-offset-4">
53+
<button type="submit" class="btn btn-primary">
54+
Login
55+
</button>
56+
57+
<a class="btn btn-link" href="{{ route('password.request') }}">
58+
Forgot Your Password?
59+
</a>
60+
</div>
61+
</div>
62+
</form>
63+
</div>
64+
</div>
65+
</div>
66+
</div>
67+
</div>
68+
@endsection
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@extends('layouts.app')
2+
3+
@section('content')
4+
<div class="container">
5+
<div class="row">
6+
<div class="col-md-8 col-md-offset-2">
7+
<div class="panel panel-default">
8+
<div class="panel-heading">Reset Password</div>
9+
<div class="panel-body">
10+
@if (session('status'))
11+
<div class="alert alert-success">
12+
{{ session('status') }}
13+
</div>
14+
@endif
15+
16+
<form class="form-horizontal" role="form" method="POST" action="{{ route('password.email') }}">
17+
{{ csrf_field() }}
18+
19+
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
20+
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
21+
22+
<div class="col-md-6">
23+
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
24+
25+
@if ($errors->has('email'))
26+
<span class="help-block">
27+
<strong>{{ $errors->first('email') }}</strong>
28+
</span>
29+
@endif
30+
</div>
31+
</div>
32+
33+
<div class="form-group">
34+
<div class="col-md-6 col-md-offset-4">
35+
<button type="submit" class="btn btn-primary">
36+
Send Password Reset Link
37+
</button>
38+
</div>
39+
</div>
40+
</form>
41+
</div>
42+
</div>
43+
</div>
44+
</div>
45+
</div>
46+
@endsection
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@extends('layouts.app')
2+
3+
@section('content')
4+
<div class="container">
5+
<div class="row">
6+
<div class="col-md-8 col-md-offset-2">
7+
<div class="panel panel-default">
8+
<div class="panel-heading">Reset Password</div>
9+
10+
<div class="panel-body">
11+
@if (session('status'))
12+
<div class="alert alert-success">
13+
{{ session('status') }}
14+
</div>
15+
@endif
16+
17+
<form class="form-horizontal" role="form" method="POST" action="{{ route('password.request') }}">
18+
{{ csrf_field() }}
19+
20+
<input type="hidden" name="token" value="{{ $token }}">
21+
22+
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
23+
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
24+
25+
<div class="col-md-6">
26+
<input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>
27+
28+
@if ($errors->has('email'))
29+
<span class="help-block">
30+
<strong>{{ $errors->first('email') }}</strong>
31+
</span>
32+
@endif
33+
</div>
34+
</div>
35+
36+
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
37+
<label for="password" class="col-md-4 control-label">Password</label>
38+
39+
<div class="col-md-6">
40+
<input id="password" type="password" class="form-control" name="password" required>
41+
42+
@if ($errors->has('password'))
43+
<span class="help-block">
44+
<strong>{{ $errors->first('password') }}</strong>
45+
</span>
46+
@endif
47+
</div>
48+
</div>
49+
50+
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
51+
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
52+
<div class="col-md-6">
53+
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
54+
55+
@if ($errors->has('password_confirmation'))
56+
<span class="help-block">
57+
<strong>{{ $errors->first('password_confirmation') }}</strong>
58+
</span>
59+
@endif
60+
</div>
61+
</div>
62+
63+
<div class="form-group">
64+
<div class="col-md-6 col-md-offset-4">
65+
<button type="submit" class="btn btn-primary">
66+
Reset Password
67+
</button>
68+
</div>
69+
</div>
70+
</form>
71+
</div>
72+
</div>
73+
</div>
74+
</div>
75+
</div>
76+
@endsection

0 commit comments

Comments
 (0)