Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Add compatibility with Laravel 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky-Loek committed Sep 9, 2019
1 parent 17683f1 commit 88071c5
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 44 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.0] - 2019-09-09
### Changed
- Add compatibility to Laravel 6.0
- Adhere to laravel/ui package structuring
### Removed
- Compatibility with Laravel 5

## [2.9.1] - 2019-07-02
### Fixed
- File paths so that the CSS and JS on login/register like views will actually load.
- File paths so that the CSS and JS on login/register like views will actually load

## [2.9.0] - 2019-06-13
### Changed
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
[![Total Downloads](https://poser.pugx.org/hz-hbo-ict/laravel-core-ui/downloads)](https://packagist.org/packages/hz-hbo-ict/laravel-core-ui)
[![License](https://poser.pugx.org/hz-hbo-ict/laravel-core-ui/license)](https://packagist.org/packages/hz-hbo-ict/laravel-core-ui)

This is a very opinionated package designed to help our freshman year's students with rapid prototyping of web applications.
This is an opinionated package designed to help our freshman year's students with rapid prototyping of web applications.

The package is based upon [CoreUI](https://coreui.io/), with every plugin we deemed unnecessary removed.
It builds upon the latest stable releases of [Laravel 5](https://laravel.com). As of now, that is version `5.8`.
It builds upon the latest stable releases of [Laravel](https://laravel.com). As of now, that is version `6.0`.

It also incorporates a replacement command for Laravel's [`make:auth`](https://laravel.com/docs/5.8/authentication#introduction) command that uses CoreUI styled views for a more consistent user experience.
It also incorporates a replacement command for Laravel's [`make:auth`](https://laravel.com/docs/6.0/authentication#introduction) command that uses CoreUI styled views for a more consistent user experience.

The result is an easy to use package that can setup a secure and complete dashboard front-end in a matter of seconds. Adding new views and features is a breeze and doesn't disrupt your normal workflow.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
}
},
"require": {
"php": ">=7.1.3",
"laravel/framework": "~5.8.0"
"php": "^7.2",
"laravel/framework": "^6.0"
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
131 changes: 131 additions & 0 deletions src/Console/CoreUIAuthCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?php

namespace HzHboIct\LaravelCoreUI\Console;

use Illuminate\Console\Command;

class CoreUIAuthCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ui:coreui
{--views : Only scaffold the authentication views}
{--force : Overwrite existing views by default}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Scaffold basic CoreUI login and registration views and routes';

/**
* The views that need to be exported.
*
* @var array
*/
protected $views = [
'auth/login.stub' => 'auth/login.blade.php',
'auth/passwords/email.stub' => 'auth/passwords/email.blade.php',
'auth/passwords/reset.stub' => 'auth/passwords/reset.blade.php',
'auth/register.stub' => 'auth/register.blade.php',
'home.stub' => 'home.blade.php',
];

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->ensureDirectoriesExist();
$this->exportViews();

if (! $this->option('views')) {
$this->exportBackend();
}

$this->info('Authentication scaffolding generated successfully.');
}

/**
* Create the directories for the files.
*
* @return void
*/
protected function ensureDirectoriesExist()
{
if (! is_dir($directory = $this->getViewPath('auth/passwords'))) {
mkdir($directory, 0755, true);
}
}

/**
* Export the authentication views.
*
* @return void
*/
protected function exportViews()
{
foreach ($this->views as $stub => $view) {
if (file_exists($view = $this->getViewPath($view)) && ! $this->option('force')) {
if (! $this->confirm('The [' . $view . '] view already exists. Do you want to replace it?')) {
continue;
}
}
copy(
__DIR__ . '/stubs/views/' . $stub,
$view
);
}
}

/**
* Export the authentication backend.
*
* @return void
*/
protected function exportBackend()
{
file_put_contents(
app_path('Http/Controllers/HomeController.php'),
$this->compileControllerStub()
);
file_put_contents(
base_path('routes/web.php'),
file_get_contents(__DIR__.'/stubs/routes.stub'),
FILE_APPEND
);
}

/**
* Compiles the "HomeController" stub.
*
* @return string
*/
protected function compileControllerStub()
{
return str_replace(
'{{namespace}}',
$this->laravel->getNamespace(),
file_get_contents(__DIR__.'/stubs/controllers/HomeController.stub')
);
}

/**
* Get full view path relative to the application's configured view path.
*
* @param string $path
* @return string
*/
protected function getViewPath($path)
{
return implode(DIRECTORY_SEPARATOR, [
config('view.paths')[0] ?? resource_path('views'), $path,
]);
}
}
29 changes: 0 additions & 29 deletions src/Console/CoreUIMakeCommand.php

This file was deleted.

28 changes: 28 additions & 0 deletions src/Console/stubs/controllers/HomeController.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace {{namespace}}Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
4 changes: 4 additions & 0 deletions src/Console/stubs/routes.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
@section('title', 'CoreUI')

@section('body')
<p>You are logged in!</p>
<p>See the <a href="https://coreui.io/docs/getting-started/introduction/" target="_blank">official CoreUI docs</a> to see how to build your amazing app!</p>

<div class="row">
<div class="col">
<div class="card text-center">
<div class="card-header">
Featured
Woohoo!
</div>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">It's a broader card with text below as a natural lead-in to extra content. This content is a little longer.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
<h5 class="card-title">You are now logged in!</h5>
<p class="card-text">Click on the button below to visit the official CoreUI documentation and learn how to build an amazing app.</p>
<a href="https://coreui.io/docs/getting-started/introduction/" target="_blank" class="btn btn-primary">Take me to CoreUI</a>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace HzHboIct\LaravelCoreUI;

use HzHboIct\LaravelCoreUI\Console\CoreUIMakeCommand;
use HzHboIct\LaravelCoreUI\Console\CoreUIAuthCommand;
use HzHboIct\LaravelCoreUI\Events\BuildingMenu;
use HzHboIct\LaravelCoreUI\Http\ViewComposers\CoreUIComposer;
use Illuminate\Contracts\Config\Repository;
Expand Down Expand Up @@ -75,7 +75,7 @@ private function publishAssets(): void

private function publishCommands(): void
{
$this->commands(CoreUIMakeCommand::class);
$this->commands(CoreUIAuthCommand::class);
}

private function publishViews(): void
Expand Down

0 comments on commit 88071c5

Please sign in to comment.