Skip to content

Commit 671405d

Browse files
committed
support for laravel 7
1 parent ea82c54 commit 671405d

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
# Laravel 6.0+ Frontend preset for Tailwind CSS
1+
# Laravel 7.0+ Frontend preset for Tailwind CSS
22

33
A Laravel front-end scaffolding preset for [Tailwind CSS](https://tailwindcss.com) - a Utility-First CSS Framework for Rapid UI Development.
44

5-
## 1. Basic usage
5+
## Usage
66

7-
1. Run `npx use-tailwind-preset`
8-
9-
## 2. Advanced Usage
10-
11-
1. Fresh install Laravel >= 6.0 and `cd` to your app.
7+
1. Fresh install Laravel >= 7.0 and `cd` to your app.
128
2. Install this preset via `composer require laravel-frontend-presets/tailwindcss --dev`. Laravel will automatically discover this package. No need to register the service provider.
139

1410
### a. For Presets without Authentication
1511

16-
1. Use `php artisan preset tailwindcss` for the basic Tailwind CSS preset
12+
1. Use `php artisan ui tailwindcss` for the basic Tailwind CSS preset
1713
2. `npm install && npm run dev`
1814
3. `php artisan serve` (or equivalent) to run server and test preset.
1915

2016
### b. For Presets with Authentication
2117

22-
1. Use `php artisan preset tailwindcss-auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`)
18+
1. Use `php artisan ui tailwindcss-auth` for the basic preset, auth route entry and Tailwind CSS auth views in one go. (NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`)
2319
4. `npm install && npm run dev`
2420
5. Configure your favorite database (mysql, sqlite etc.)
2521
6. `php artisan migrate` to create basic user tables.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"keywords": ["laravel", "preset", "tailwindcss"],
55
"license": "MIT",
66
"require": {
7-
"laravel/framework": "^5.5 || ^6.0"
7+
"laravel/framework": "^7.0",
8+
"laravel/ui": "^2.0"
89
},
910
"autoload": {
1011
"psr-4": {

src/TailwindCssPreset.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace LaravelFrontendPresets\TailwindCssPreset;
44

55
use Illuminate\Support\Arr;
6+
use Illuminate\Support\Str;
67
use Illuminate\Container\Container;
78
use Illuminate\Filesystem\Filesystem;
8-
use Illuminate\Foundation\Console\Presets\Preset;
9+
use Laravel\Ui\Presets\Preset;
10+
use Symfony\Component\Finder\SplFileInfo;
911

1012
class TailwindCssPreset extends Preset
1113
{
@@ -15,13 +17,13 @@ public static function install()
1517
static::updateStyles();
1618
static::updateBootstrapping();
1719
static::updateWelcomePage();
18-
static::updatePagination();
1920
static::removeNodeModules();
2021
}
2122

2223
public static function installAuth()
2324
{
2425
static::install();
26+
static::scaffoldController();
2527
static::scaffoldAuth();
2628
}
2729

@@ -73,11 +75,21 @@ protected static function updateWelcomePage()
7375
copy(__DIR__.'/tailwindcss-stubs/resources/views/welcome.blade.php', resource_path('views/welcome.blade.php'));
7476
}
7577

76-
protected static function updatePagination()
78+
protected static function scaffoldController()
7779
{
78-
(new Filesystem)->delete(resource_path('views/vendor/paginate'));
79-
80-
(new Filesystem)->copyDirectory(__DIR__.'/tailwindcss-stubs/resources/views/vendor/pagination', resource_path('views/vendor/pagination'));
80+
if (! is_dir($directory = app_path('Http/Controllers/Auth'))) {
81+
mkdir($directory, 0755, true);
82+
}
83+
84+
$filesystem = new Filesystem;
85+
86+
collect($filesystem->allFiles(base_path('vendor/laravel/ui/stubs/Auth')))
87+
->each(function (SplFileInfo $file) use ($filesystem) {
88+
$filesystem->copy(
89+
$file->getPathname(),
90+
app_path('Http/Controllers/Auth/'.Str::replaceLast('.stub', '.php', $file->getFilename()))
91+
);
92+
});
8193
}
8294

8395
protected static function scaffoldAuth()

src/TailwindCssPresetServiceProvider.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@
22

33
namespace LaravelFrontendPresets\TailwindCssPreset;
44

5-
use Illuminate\Pagination\Paginator;
65
use Illuminate\Support\ServiceProvider;
7-
use Illuminate\Foundation\Console\PresetCommand;
6+
use Laravel\Ui\UiCommand;
87

98
class TailwindCssPresetServiceProvider extends ServiceProvider
109
{
1110
public function boot()
1211
{
13-
PresetCommand::macro('tailwindcss', function ($command) {
12+
UiCommand::macro('tailwindcss', function ($command) {
1413
TailwindCssPreset::install();
1514

1615
$command->info('Tailwind CSS scaffolding installed successfully.');
17-
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
16+
$command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
1817
});
1918

20-
PresetCommand::macro('tailwindcss-auth', function ($command) {
19+
UiCommand::macro('tailwindcss-auth', function ($command) {
2120
TailwindCssPreset::installAuth();
2221

2322
$command->info('Tailwind CSS scaffolding with auth views installed successfully.');
24-
$command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
23+
$command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
2524
});
26-
27-
Paginator::defaultView('pagination::default');
28-
29-
Paginator::defaultSimpleView('pagination::simple-default');
3025
}
3126
}

0 commit comments

Comments
 (0)