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

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalinfyom committed Dec 12, 2020
0 parents commit 4c3581b
Show file tree
Hide file tree
Showing 78 changed files with 236,155 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
/vendor/
composer.lock
.DS_Store
**/.DS_Store
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Laravel UI AdminLTE

[![Total Downloads](https://poser.pugx.org/infyomlabs/laravel-ui-adminlte/downloads)](https://packagist.org/packages/infyomlabs/laravel-ui-adminlte)
[![Monthly Downloads](https://poser.pugx.org/infyomlabs/laravel-ui-adminlte/d/monthly)](https://packagist.org/packages/infyomlabs/laravel-ui-adminlte)
[![Daily Downloads](https://poser.pugx.org/infyomlabs/laravel-ui-adminlte/d/daily)](https://packagist.org/packages/infyomlabs/laravel-ui-adminlte)
[![License](https://poser.pugx.org/infyomlabs/laravel-ui-adminlte/license)](https://packagist.org/packages/infyomlabs/laravel-ui-adminlte)

[Laravel Frontend Scaffolding](https://laravel.com/docs/7.x/frontend) for [AdminLTE3](https://adminlte.io/themes/v3/) Theme.

## Installation

Run a command,

`composer require infyomlabs/laravel-ui-adminlte`

For Laravel 7,

`composer require infyomlabs/laravel-ui-adminlte:^2.0`

For Laravel 6,

`composer require infyomlabs/laravel-ui-adminlte:^1.0`

## Usage

Run a command,

To Generate a full authentication UI,

`php artisan ui adminlte --auth`

To Install just AdminLTE theme assets,

`php artisan ui adminlte`

And then run,

`npm install && npm run dev`

Or for production,

`npm install && npm run prod`

## Usage with Laravel Fortify (Laravel 8.x only)

This package also provides support for Laravel Fortify for authentication scaffolding.

**NOTE**: Don't forget to install and run Laravel Fortify and perform its required installation steps.

Run a command,

`php artisan ui adminlte-fortify --auth`

And then run,

`npm install && npm run dev`

Or for production,

`npm install && npm run prod`

## Tutorial
Here you can find a video tutorial. (**Credits**: [shailesh-ladumor](https://github.com/shailesh-ladumor))

[<img src="https://img.youtube.com/vi/jA7hr2gE9yc/0.jpg" width="480">](https://youtu.be/jA7hr2gE9yc)

## Screenshots

### Login

![Login](https://raw.github.com/InfyOmLabs/laravel-ui-adminlte/master/screenshots/Login.png)

### Register

![Register](https://raw.github.com/InfyOmLabs/laravel-ui-adminlte/master/screenshots/Register.png)

### Reset Password Form

![Reset Password Form](https://raw.github.com/InfyOmLabs/laravel-ui-adminlte/master/screenshots/Reset-Password-Form.png)

### Reset Password

![Reset Password](https://raw.github.com/InfyOmLabs/laravel-ui-adminlte/master/screenshots/Reset-Password.png)

### Admin Layout

![Reset Password](https://raw.github.com/InfyOmLabs/laravel-ui-adminlte/master/screenshots/Admin-Layout.png)
36 changes: 36 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "infyomlabs/laravel-ui-stisla",
"description": "Laravel frontend preset for Stisla Theme",
"keywords": [
"laravel",
"preset",
"stisla"
],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Mitul Golakiya",
"email": "[email protected]"
}
],
"require": {
"php": "^7.3",
"illuminate/support": "^8.0",
"infyomlabs/laravel-generator-helpers": "^3.0",
"laravel/ui": "^3.0"
},
"autoload": {
"psr-4": {
"InfyOm\\StislaPreset\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"InfyOm\\StislaPreset\\StislaPresetServiceProvider",
"InfyOm\\StislaPreset\\FortifyStislaPresetServiceProvider"
]
}
}
}
Binary file added screenshots/Admin-Layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Edit-Profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Register.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Reset-Password-Form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/Reset-Password.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions src/FortifyStislaPresetServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace InfyOm\StislaPreset;

use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Fortify;
use Laravel\Ui\UiCommand;

class FortifyStislaPresetServiceProvider extends ServiceProvider
{
public function boot()
{
UiCommand::macro('stisla-fortify', function (UiCommand $command) {
$fortifyAdminLTEPreset = new StislaPreset($command, true);
$fortifyAdminLTEPreset->install();

$command->info('Stisla scaffolding installed successfully for Laravel Fortify.');

if ($command->option('auth')) {
$fortifyAdminLTEPreset->installAuth();
$command->info('Stisla CSS auth scaffolding installed successfully for Laravel Fortify.');
}

$command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
});

if (class_exists(Fortify::class)) {
Fortify::loginView(function () {
return view('auth.login');
});

Fortify::registerView(function () {
return view('auth.register');
});

Fortify::confirmPasswordView(function () {
return view('auth.passwords.confirm');
});

Fortify::requestPasswordResetLinkView(function () {
return view('auth.passwords.email');
});

Fortify::resetPasswordView(function () {
return view('auth.passwords.reset');
});

Fortify::verifyEmailView(function () {
return view('auth.verify');
});
}
}
}
189 changes: 189 additions & 0 deletions src/StislaPreset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?php

namespace InfyOm\StislaPreset;

use Illuminate\Console\Command;
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use InfyOm\GeneratorHelpers\LaravelUtils;
use Laravel\Ui\Presets\Preset;
use Symfony\Component\Finder\SplFileInfo;


class StislaPreset extends Preset
{
/** @var Command */
protected $command;

public $isFortify = false;

public function __construct(Command $command, $isFortify = false)
{
$this->command = $command;
$this->isFortify = $isFortify;
}

/**
* Update the given package array.
*
* @param array $packages
*
* @return array
*/
protected static function updatePackageArray(array $packages)
{
return [
"bootstrap" => "^4.0.0",
"jquery" => "^3.2",
"popper.js" => "^1.12",
"sass" => "^1.15.2",
"sass-loader" => "^7.1.0",
"@fortawesome/fontawesome-free" => "^5.13.1",
"jquery.nicescroll" => "^3.7.6",
"vue-template-compiler" => "^2.6.12",
"vue" => "^2.5.17",
"datatables.net-dt" => "^1.10.21",
"jsrender" => "^1.0.5",
"sweetalert" => "^1.1.3",
"select2" => "^4.0.13",
"izitoast" => "^1.4.0",
] + $packages;
}

public function install()
{
static::updatePackages(false);
static::updateWebpackConfiguration();
static::removeNodeModules();
static::addMiscellaneousAssets();
}

/**
* Update the Webpack configuration.
*
* @return void
*/
protected static function updateWebpackConfiguration()
{
copy(__DIR__.'/../stisla-stubs/vendors/bootstrap/webpack.mix.js', base_path('webpack.mix.js'));
}


public function installAuth()
{
$viewsPath = LaravelUtils::getViewPath();

$this->ensureDirectoriesExist($viewsPath);

$this->scaffoldAuth();

if (! $this->isFortify) {
$this->scaffoldController();
}
}

protected function ensureDirectoriesExist($viewsPath)
{
if (! file_exists($viewsPath.'layouts')) {
mkdir($viewsPath.'layouts', 0755, true);
}

if (! file_exists($viewsPath.'profile')) {
mkdir($viewsPath.'profile', 0755, true);
}

if (! file_exists($viewsPath.'auth')) {
mkdir($viewsPath.'auth', 0755, true);
}

if (! file_exists($viewsPath.'auth/passwords')) {
mkdir($viewsPath.'auth/passwords', 0755, true);
}
}

private function addAuthRoutes()
{
file_put_contents(
base_path('routes/web.php'),
"\nAuth::routes();\n",
FILE_APPEND
);
}

private function addHomeRoute()
{
file_put_contents(
base_path('routes/web.php'),
"\nRoute::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');\n",
FILE_APPEND
);
}

protected function scaffoldController()
{
if (! is_dir($directory = app_path('Http/Controllers/Auth'))) {
mkdir($directory, 0755, true);
}

$filesystem = new Filesystem();

collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/Auth')))
->each(function (SplFileInfo $file) use ($filesystem) {
$filesystem->copy(
$file->getPathname(),
app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename()))
);
});
}

protected function scaffoldAuth()
{
file_put_contents(app_path('Http/Controllers/HomeController.php'), $this->compileHomeControllerStub());

$this->addHomeRoute();

if (! $this->isFortify) {
$this->addAuthRoutes();
}

tap(new Filesystem(), function ($filesystem) {
$filesystem->copyDirectory(__DIR__.'/../stisla-stubs/views/auth', resource_path('views/auth'));
$filesystem->copyDirectory(__DIR__.'/../stisla-stubs/views/layouts', resource_path('views/layouts'));
$filesystem->copyDirectory(__DIR__.'/../stisla-stubs/views/profile', resource_path('views/profile'));
$filesystem->copy(__DIR__.'/../stisla-stubs/home.blade.php', resource_path('views/home.blade.php'));


collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/migrations')))
->each(function (SplFileInfo $file) use ($filesystem) {
$filesystem->copy(
$file->getPathname(),
database_path('migrations/'.$file->getFilename())
);
});
});
}

protected function compileHomeControllerStub()
{
return str_replace(
'{{namespace}}',
Container::getInstance()->getNamespace(),
file_get_contents(base_path('vendor/laravel/ui/src/Auth/stubs/controllers/HomeController.stub'))
);
}

/**
* Update the Webpack configuration.
*
* @return void
*/
protected static function addMiscellaneousAssets()
{
$filesystem = new Filesystem();

$filesystem->copyDirectory(__DIR__.'/../stisla-stubs/vendors/resources/assets', resource_path('/assets/'));
$filesystem->copyDirectory(__DIR__.'/../stisla-stubs/vendors/resources/js', resource_path('/js/'));
$filesystem->copyDirectory(__DIR__.'/../stisla-stubs/vendors/public', base_path('public/'));
}
}
Loading

0 comments on commit 4c3581b

Please sign in to comment.