Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Commit f4c84df

Browse files
committed
feat: package created
0 parents  commit f4c84df

File tree

5 files changed

+262
-0
lines changed

5 files changed

+262
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
/vendor/
3+
composer.lock

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Laravel UI CoreUI
2+
3+
[Laravel Frontend Scaffolding](https://laravel.com/docs/7.x/frontend) for [CoreUI](https://coreui.io/) Theme.
4+
5+
## Installation
6+
7+
Run a command,
8+
9+
`composer require infyomlabs/laravel-ui-coreui`
10+
11+
For Laravel 6,
12+
13+
`composer require infyomlabs/laravel-ui-coreui:^1.0`
14+
15+
## Usage
16+
17+
Run a command,
18+
19+
To Generate a full authentication UI,
20+
21+
`php artisan ui coreui --auth`
22+
23+
To Install just CoreUI theme assets,
24+
25+
`php artisan ui coreui`
26+
27+
And then run,
28+
29+
`npm install && npm run dev`
30+
31+
Or for production,
32+
33+
`npm install && npm run prod`
34+
35+
## Screenshots
36+
37+
### Login
38+
39+
![Login](https://raw.github.com/InfyOmLabs/laravel-ui-coreui/master/screenshots/Login.png)
40+
41+
### Register
42+
43+
![Register](https://raw.github.com/InfyOmLabs/laravel-ui-coreui/master/screenshots/Register.png)
44+
45+
### Reset Password Form
46+
47+
![Reset Password Form](https://raw.github.com/InfyOmLabs/laravel-ui-coreui/master/screenshots/Reset-Password-Form.png)
48+
49+
### Reset Password
50+
51+
![Reset Password](https://raw.github.com/InfyOmLabs/laravel-ui-coreui/master/screenshots/Reset-Password.png)

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
{
3+
"name": "infyomlabs/laravel-ui-coreui",
4+
"description": "Laravel frontend preset for CoreUI Theme",
5+
"keywords": [
6+
"laravel",
7+
"preset",
8+
"coreui"
9+
],
10+
"type": "library",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Mitul Golakiya",
15+
"email": "me@mitul.me"
16+
}
17+
],
18+
"require": {
19+
"php": "^7.2.5",
20+
"illuminate/support": "^7.0",
21+
"infyomlabs/laravel-generator-helpers": "^2.0",
22+
"laravel/ui": "^2.0"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"InfyOm\\CoreUIPreset\\": "src/"
27+
}
28+
},
29+
"extra": {
30+
"laravel": {
31+
"providers": [
32+
"InfyOm\\CoreUIPreset\\CoreUIPresetServiceProvider"
33+
]
34+
}
35+
}
36+
}

src/CoreUIPreset.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
3+
namespace InfyOm\CoreUIPreset;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Container\Container;
7+
use Illuminate\Filesystem\Filesystem;
8+
use Illuminate\Support\Str;
9+
use InfyOm\GeneratorHelpers\LaravelUtils;
10+
use Laravel\Ui\Presets\Preset;
11+
use Symfony\Component\Finder\SplFileInfo;
12+
13+
class CoreUIPreset extends Preset
14+
{
15+
/** @var Command */
16+
protected $command;
17+
18+
public function __construct(Command $command)
19+
{
20+
$this->command = $command;
21+
}
22+
23+
/**
24+
* Update the given package array.
25+
*
26+
* @param array $packages
27+
* @return array
28+
*/
29+
protected static function updatePackageArray(array $packages)
30+
{
31+
return [
32+
'bootstrap' => '^4.0.0',
33+
'jquery' => '^3.2',
34+
'popper.js' => '^1.12',
35+
'@coreui/coreui' => '^3.2.2',
36+
] + $packages;
37+
}
38+
39+
public function install()
40+
{
41+
static::updatePackages();
42+
static::updateSass();
43+
static::updateBootstrapping();
44+
static::removeNodeModules();
45+
}
46+
47+
/**
48+
* Update the Sass files for the application.
49+
*
50+
* @return void
51+
*/
52+
protected static function updateSass()
53+
{
54+
copy(__DIR__.'/../coreui-stubs/bootstrap/_variables.scss', resource_path('sass/_variables.scss'));
55+
copy(__DIR__.'/../coreui-stubs/bootstrap/app.scss', resource_path('sass/app.scss'));
56+
}
57+
58+
/**
59+
* Update the bootstrapping files.
60+
*
61+
* @return void
62+
*/
63+
protected static function updateBootstrapping()
64+
{
65+
copy(__DIR__.'/../coreui-stubs/bootstrap/bootstrap.js', resource_path('js/bootstrap.js'));
66+
copy(__DIR__.'/../coreui-stubs/bootstrap/app.js', resource_path('js/app.js'));
67+
}
68+
69+
public function installAuth()
70+
{
71+
$viewsPath = LaravelUtils::getViewPath();
72+
73+
$this->ensureDirectoriesExist($viewsPath);
74+
75+
$this->scaffoldAuth();
76+
$this->scaffoldController();
77+
}
78+
79+
protected function ensureDirectoriesExist($viewsPath)
80+
{
81+
if (!file_exists($viewsPath.'layouts')) {
82+
mkdir($viewsPath.'layouts', 0755, true);
83+
}
84+
85+
if (!file_exists($viewsPath.'auth')) {
86+
mkdir($viewsPath.'auth', 0755, true);
87+
}
88+
89+
if (!file_exists($viewsPath.'auth/passwords')) {
90+
mkdir($viewsPath.'auth/passwords', 0755, true);
91+
}
92+
}
93+
94+
protected function scaffoldController()
95+
{
96+
if (!is_dir($directory = app_path('Http/Controllers/Auth'))) {
97+
mkdir($directory, 0755, true);
98+
}
99+
100+
$filesystem = new Filesystem;
101+
102+
collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/Auth')))
103+
->each(function (SplFileInfo $file) use ($filesystem) {
104+
$filesystem->copy(
105+
$file->getPathname(),
106+
app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename()))
107+
);
108+
});
109+
}
110+
111+
protected function scaffoldAuth()
112+
{
113+
file_put_contents(app_path('Http/Controllers/HomeController.php'), $this->compileHomeControllerStub());
114+
115+
file_put_contents(
116+
base_path('routes/web.php'),
117+
"Auth::routes();\n\nRoute::get('/home', 'HomeController@index')->name('home');\n\n",
118+
FILE_APPEND
119+
);
120+
121+
tap(new Filesystem, function ($filesystem) {
122+
123+
$filesystem->copyDirectory(__DIR__.'/../coreui-stubs/auth', resource_path('views/auth'));
124+
$filesystem->copyDirectory(__DIR__.'/../coreui-stubs/layouts', resource_path('views/layouts'));
125+
$filesystem->copy(__DIR__.'/../coreui-stubs/home.blade.php', resource_path('views/home.blade.php'));
126+
127+
collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/migrations')))
128+
->each(function (SplFileInfo $file) use ($filesystem) {
129+
$filesystem->copy(
130+
$file->getPathname(),
131+
database_path('migrations/'.$file->getFilename())
132+
);
133+
});
134+
});
135+
}
136+
137+
protected function compileHomeControllerStub()
138+
{
139+
return str_replace(
140+
'{{namespace}}',
141+
Container::getInstance()->getNamespace(),
142+
file_get_contents(base_path('vendor/laravel/ui/src/Auth/stubs/controllers/HomeController.stub'))
143+
);
144+
}
145+
}

src/CoreUIPresetServiceProvider.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace InfyOm\CoreUIPreset;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Laravel\Ui\UiCommand;
7+
8+
class CoreUIPresetServiceProvider extends ServiceProvider
9+
{
10+
public function boot()
11+
{
12+
UiCommand::macro('coreui', function (UiCommand $command) {
13+
14+
$coreUIPreset = new CoreUIPreset($command);
15+
$coreUIPreset->install();
16+
17+
$command->info('CoreUI scaffolding installed successfully.');
18+
19+
if ($command->option('auth')) {
20+
$coreUIPreset->installAuth();
21+
$command->info('CoreUI CSS auth scaffolding installed successfully.');
22+
}
23+
24+
$command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
25+
});
26+
}
27+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy