| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,96 @@ | |||
| 1 | + <?php | ||
| 2 | + | ||
| 3 | + namespace Illuminate\Auth\Console; | ||
| 4 | + | ||
| 5 | + use Illuminate\Console\Command; | ||
| 6 | + | ||
| 7 | + class MakeAuthCommand extends Command | ||
| 8 | + { | ||
| 9 | + /** | ||
| 10 | + * The console command name. | ||
| 11 | + * | ||
| 12 | + * @var string | ||
| 13 | + */ | ||
| 14 | + protected $name = 'make:auth'; | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * The console command description. | ||
| 18 | + * | ||
| 19 | + * @var string | ||
| 20 | + */ | ||
| 21 | + protected $description = 'Scaffold basic login and registration views and routes'; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * THe views that need to be exported. | ||
| 25 | + * | ||
| 26 | + * @var array | ||
| 27 | + */ | ||
| 28 | + protected $views = [ | ||
| 29 | + 'auth/login.stub' => 'auth/login.blade.php', | ||
| 30 | + 'auth/register.stub' => 'auth/register.blade.php', | ||
| 31 | + 'auth/passwords/email.stub' => 'auth/passwords/email.blade.php', | ||
| 32 | + 'auth/passwords/reset.stub' => 'auth/passwords/reset.blade.php', | ||
| 33 | + 'auth/emails/password.stub' => 'auth/emails/password.blade.php', | ||
| 34 | + 'layouts/app.stub' => 'layouts/app.blade.php', | ||
| 35 | + 'home.stub' => 'home.blade.php', | ||
| 36 | + 'welcome.stub' => 'welcome.blade.php', | ||
| 37 | + ]; | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * Execute the console command. | ||
| 41 | + * | ||
| 42 | + * @return void | ||
| 43 | + */ | ||
| 44 | + public function fire() | ||
| 45 | + { | ||
| 46 | + $this->createDirectories(); | ||
| 47 | + | ||
| 48 | + $this->exportViews(); | ||
| 49 | + | ||
| 50 | + $this->info('Installed HomeController.'); | ||
| 51 | + | ||
| 52 | + copy(__DIR__.'/stubs/make/controllers/HomeController.stub', app_path('Http/Controllers/HomeController.php')); | ||
| 53 | + | ||
| 54 | + $this->info('Updated Routes File.'); | ||
| 55 | + | ||
| 56 | + copy(__DIR__.'/stubs/make/routes.stub', app_path('Http/routes.php')); | ||
| 57 | + | ||
| 58 | + $this->comment('Authentication scaffolding generated successfully!'); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * Create the directories for the files. | ||
| 63 | + * | ||
| 64 | + * @return void | ||
| 65 | + */ | ||
| 66 | + protected function createDirectories() | ||
| 67 | + { | ||
| 68 | + if (! is_dir(base_path('resources/views/layouts'))) { | ||
| 69 | + mkdir(base_path('resources/views/layouts'), 0755, true); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + if (! is_dir(base_path('resources/views/auth/passwords'))) { | ||
| 73 | + mkdir(base_path('resources/views/auth/passwords'), 0755, true); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + if (! is_dir(base_path('resources/views/auth/emails'))) { | ||
| 77 | + mkdir(base_path('resources/views/auth/emails'), 0755, true); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * Export the authentication views. | ||
| 83 | + * | ||
| 84 | + * @return void | ||
| 85 | + */ | ||
| 86 | + protected function exportViews() | ||
| 87 | + { | ||
| 88 | + foreach ($this->views as $key => $value) { | ||
| 89 | + $path = base_path('resources/views/'.$value); | ||
| 90 | + | ||
| 91 | + $this->line('<info>Created View:</info> '.$path); | ||
| 92 | + | ||
| 93 | + copy(__DIR__.'/stubs/make/views/'.$key, $path); | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + <?php | ||
| 2 | + | ||
| 3 | + namespace App\Http\Controllers; | ||
| 4 | + | ||
| 5 | + use Illuminate\Http\Request; | ||
| 6 | + | ||
| 7 | + use App\Http\Requests; | ||
| 8 | + use App\Http\Controllers\Controller; | ||
| 9 | + | ||
| 10 | + class HomeController extends Controller | ||
| 11 | + { | ||
| 12 | + /** | ||
| 13 | + * Create a new controller instance. | ||
| 14 | + * | ||
| 15 | + * @return void | ||
| 16 | + */ | ||
| 17 | + public function __construct() | ||
| 18 | + { | ||
| 19 | + $this->middleware('auth'); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * Show the application dashboard. | ||
| 24 | + * | ||
| 25 | + * @return Response | ||
| 26 | + */ | ||
| 27 | + public function index() | ||
| 28 | + { | ||
| 29 | + return view('home'); | ||
| 30 | + } | ||
| 31 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + <?php | ||
| 2 | + | ||
| 3 | + /* | ||
| 4 | + |-------------------------------------------------------------------------- | ||
| 5 | + | Application Routes | ||
| 6 | + |-------------------------------------------------------------------------- | ||
| 7 | + | | ||
| 8 | + | Here is where you can register all of the routes in an application. | ||
| 9 | + | It's a breeze. Simply tell Laravel the URIs it should respond to | ||
| 10 | + | and give it the controller to call when that URI is requested. | ||
| 11 | + | | ||
| 12 | + */ | ||
| 13 | + | ||
| 14 | + Route::get('/', function () { | ||
| 15 | + return view('welcome'); | ||
| 16 | + }); | ||
| 17 | + | ||
| 18 | + /* | ||
| 19 | + | This route group applies the "web" middleware group to every route | ||
| 20 | + | it contains. The "web" middleware group is defined in your HTTP | ||
| 21 | + | kernel and includes session state, CSRF protection, and more. | ||
| 22 | + */ | ||
| 23 | + | ||
| 24 | + Route::group(['middleware' => 'web'], function () { | ||
| 25 | + Route::auth(); | ||
| 26 | + | ||
| 27 | + Route::get('/home', 'HomeController@index'); | ||
| 28 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments