Skip to content

Commit 330d3f7

Browse files
authored
Merge pull request #18 from neilherbertuk/master
Laravel 5.7 support
2 parents 8fb0f06 + 9a486a0 commit 330d3f7

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Laravel 5.5/5.6 Front-end Preset For Tabler Dashboard UI Kit
1+
# Laravel 5.5+ Front-end Preset For Tabler Dashboard UI Kit
22

33
[![Latest Stable Version](https://poser.pugx.org/cesaramirez/laravel-tabler/v/stable)](https://packagist.org/packages/cesaramirez/laravel-tabler)
44

5-
Preset for [Tabler](https://tabler.github.io/) scaffolding on new Laravel 5.5/5.6 project.
5+
Preset for [Tabler](https://tabler.github.io/) scaffolding on a new Laravel 5.5 or above project.
66

77
## Usage
88

9-
1. Fresh install Laravel 5.5/5.6 and `cd` to your app.
10-
2. Install this preset via `composer require cesaramirez/laravel-tabler`. Laravel 5.5/5.6 will automatically discover this package. No need to register the service provider.
9+
1. Fresh install Laravel 5.5 or above and `cd` to your app.
10+
2. Install this preset via `composer require cesaramirez/laravel-tabler`. Laravel 5.5+ will automatically discover this package. No need to register the service provider.
1111
3. Use `php artisan preset tabler` for basic Tabler preset. **OR** Use `php artisan preset tabler-auth` for basic preset, Auth route entry and Tabler 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`)
1212
4. `yarn`
1313
5. `yarn dev` or `yarn watch`
1414
6. Configure your favorite database (mysql, sqlite, etc.)
1515
7. `php artisan migrate` to create basic user tables.
16-
8. `php artisan serve` (or equivalent) to run server and test preset.
16+
8. `php artisan serve` (or equivalent) to run server and test preset.

src/TablerPreset.php

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ protected static function updatePackageArray(array $packages)
4848
*/
4949
protected static function updateAssets()
5050
{
51-
copy(__DIR__.'/tabler-stubs/sass/app.scss', resource_path('assets/sass/app.scss'));
52-
copy(__DIR__.'/tabler-stubs/sass/_variables.scss', resource_path('assets/sass/_variables.scss'));
53-
(new Filesystem())->copyDirectory(__DIR__.'/tabler-stubs/sass/tabler', resource_path('assets/sass/tabler'));
54-
(new Filesystem())->copyDirectory(__DIR__.'/tabler-stubs/fonts', resource_path('assets/fonts'));
51+
copy(__DIR__.'/tabler-stubs/sass/app.scss', static::getResourcePath('sass/app.scss'));
52+
copy(__DIR__.'/tabler-stubs/sass/_variables.scss', static::getResourcePath('sass/_variables.scss'));
53+
(new Filesystem())->copyDirectory(__DIR__.'/tabler-stubs/sass/tabler', static::getResourcePath('sass/tabler'));
54+
(new Filesystem())->copyDirectory(__DIR__.'/tabler-stubs/fonts', static::getResourcePath('fonts'));
5555
}
5656

5757
/**
@@ -60,7 +60,18 @@ protected static function updateAssets()
6060
protected static function updateBootstrapping()
6161
{
6262
copy(__DIR__.'/tabler-stubs/webpack.mix.js', base_path('webpack.mix.js'));
63-
copy(__DIR__.'/tabler-stubs/bootstrap.js', resource_path('assets/js/bootstrap.js'));
63+
64+
if (!self::expectsAssetsFolder()) {
65+
file_put_contents(base_path('webpack.mix.js'),
66+
str_replace(
67+
'assets/',
68+
'',
69+
file_get_contents(base_path('webpack.mix.js'))
70+
)
71+
);
72+
}
73+
74+
copy(__DIR__.'/tabler-stubs/bootstrap.js', static::getResourcePath('js/bootstrap.js'));
6475
}
6576

6677
/**
@@ -90,4 +101,30 @@ protected static function compileControllerStub()
90101
file_get_contents(__DIR__.'/tabler-stubs/controllers/HomeController.stub')
91102
);
92103
}
104+
105+
/**
106+
* Gets resource path depending on version of Laravel.
107+
*
108+
* @param string $path
109+
*
110+
* @return string
111+
*/
112+
protected static function getResourcePath($path = '')
113+
{
114+
if (self::expectsAssetsFolder()) {
115+
return resource_path('assets/'.$path);
116+
}
117+
118+
return resource_path($path);
119+
}
120+
121+
/**
122+
* Should we expect to see an assets folder within this version of Laravel?
123+
*
124+
* @return bool
125+
*/
126+
protected static function expectsAssetsFolder()
127+
{
128+
return (int) str_replace('.', '', app()->version()) < 570;
129+
}
93130
}

0 commit comments

Comments
 (0)