Skip to content

Commit 4038405

Browse files
committed
Part 13 code - working with sessions and messages
0 parents  commit 4038405

File tree

94 files changed

+6065
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+6065
-0
lines changed

.env.example

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
APP_ENV=local
2+
APP_DEBUG=true
3+
APP_KEY=SomeRandomString
4+
5+
DB_HOST=localhost
6+
DB_DATABASE=homestead
7+
DB_USERNAME=homestead
8+
DB_PASSWORD=secret
9+
10+
CACHE_DRIVER=file
11+
SESSION_DRIVER=file
12+
QUEUE_DRIVER=sync
13+
14+
REDIS_HOST=localhost
15+
REDIS_PASSWORD=null
16+
REDIS_PORT=6379
17+
18+
MAIL_DRIVER=smtp
19+
MAIL_HOST=mailtrap.io
20+
MAIL_PORT=2525
21+
MAIL_USERNAME=null
22+
MAIL_PASSWORD=null
23+
MAIL_ENCRYPTION=null

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.less linguist-vendored

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/vendor
2+
/node_modules
3+
Homestead.yaml
4+
Homestead.json
5+
.env

app/Console/Commands/Inspire.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Foundation\Inspiring;
7+
8+
class Inspire extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'inspire';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Display an inspiring quote';
23+
24+
/**
25+
* Execute the console command.
26+
*
27+
* @return mixed
28+
*/
29+
public function handle()
30+
{
31+
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
32+
}
33+
}

app/Console/Kernel.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
Commands\Inspire::class,
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
$schedule->command('inspire')
28+
->hourly();
29+
}
30+
}

app/Events/Event.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
abstract class Event
6+
{
7+
//
8+
}

app/Exceptions/Handler.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Illuminate\Auth\Access\AuthorizationException;
7+
use Illuminate\Database\Eloquent\ModelNotFoundException;
8+
use Symfony\Component\HttpKernel\Exception\HttpException;
9+
use Illuminate\Foundation\Validation\ValidationException;
10+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
11+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
12+
13+
class Handler extends ExceptionHandler
14+
{
15+
/**
16+
* A list of the exception types that should not be reported.
17+
*
18+
* @var array
19+
*/
20+
protected $dontReport = [
21+
AuthorizationException::class,
22+
HttpException::class,
23+
ModelNotFoundException::class,
24+
ValidationException::class,
25+
];
26+
27+
/**
28+
* Report or log an exception.
29+
*
30+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
31+
*
32+
* @param \Exception $e
33+
* @return void
34+
*/
35+
public function report(Exception $e)
36+
{
37+
return parent::report($e);
38+
}
39+
40+
/**
41+
* Render an exception into an HTTP response.
42+
*
43+
* @param \Illuminate\Http\Request $request
44+
* @param \Exception $e
45+
* @return \Illuminate\Http\Response
46+
*/
47+
public function render($request, Exception $e)
48+
{
49+
return parent::render($request, $e);
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\User;
6+
use Validator;
7+
use App\Http\Controllers\Controller;
8+
use Illuminate\Foundation\Auth\ThrottlesLogins;
9+
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
10+
11+
class AuthController extends Controller
12+
{
13+
/*
14+
|--------------------------------------------------------------------------
15+
| Registration & Login Controller
16+
|--------------------------------------------------------------------------
17+
|
18+
| This controller handles the registration of new users, as well as the
19+
| authentication of existing users. By default, this controller uses
20+
| a simple trait to add these behaviors. Why don't you explore it?
21+
|
22+
*/
23+
24+
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
25+
26+
/**
27+
* Where to redirect users after login / registration.
28+
*
29+
* @var string
30+
*/
31+
protected $redirectTo = '/home';
32+
33+
/**
34+
* Create a new authentication controller instance.
35+
*
36+
* @return void
37+
*/
38+
public function __construct()
39+
{
40+
$this->middleware('guest', ['except' => 'logout']);
41+
}
42+
43+
/**
44+
* Get a validator for an incoming registration request.
45+
*
46+
* @param array $data
47+
* @return \Illuminate\Contracts\Validation\Validator
48+
*/
49+
protected function validator(array $data)
50+
{
51+
return Validator::make($data, [
52+
'name' => 'required|max:255',
53+
'email' => 'required|email|max:255|unique:users',
54+
'password' => 'required|confirmed|min:6',
55+
]);
56+
}
57+
58+
/**
59+
* Create a new user instance after a valid registration.
60+
*
61+
* @param array $data
62+
* @return User
63+
*/
64+
protected function create(array $data)
65+
{
66+
return User::create([
67+
'name' => $data['name'],
68+
'email' => $data['email'],
69+
'password' => bcrypt($data['password']),
70+
]);
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\ResetsPasswords;
7+
8+
class PasswordController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Password Reset Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller is responsible for handling password reset requests
16+
| and uses a simple trait to include this behavior. You're free to
17+
| explore this trait and override any methods you wish to tweak.
18+
|
19+
*/
20+
21+
use ResetsPasswords;
22+
23+
/**
24+
* Create a new password controller instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
$this->middleware('guest');
31+
}
32+
}

app/Http/Controllers/Controller.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Foundation\Bus\DispatchesJobs;
6+
use Illuminate\Routing\Controller as BaseController;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
9+
10+
class Controller extends BaseController
11+
{
12+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
class PagesController extends Controller {
6+
7+
public function getIndex() {
8+
return view('pages.welcome');
9+
}
10+
11+
public function getAbout() {
12+
$first = 'Alex';
13+
$last = 'Curtis';
14+
15+
$fullname = $first . " " . $last;
16+
$email = '[email protected]';
17+
$data = [];
18+
$data['email'] = $email;
19+
$data['fullname'] = $fullname;
20+
return view('pages.about')->withData($data);
21+
}
22+
23+
public function getContact() {
24+
return view('pages.contact');
25+
}
26+
27+
28+
}

0 commit comments

Comments
 (0)