Skip to content

Commit ce84d7d

Browse files
authored
🔀 merge develop branch
merge develop
2 parents ebe81b0 + 4626e23 commit ce84d7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6691
-1
lines changed

.php_cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
/**
7+
* Config for PHP-CS-Fixer ver2.
8+
*/
9+
$rules = [
10+
'@PSR2' => true,
11+
'@Symfony' => true,
12+
'array_syntax' => ['syntax' => 'short'],
13+
'no_multiline_whitespace_before_semicolons' => true,
14+
'no_short_echo_tag' => true,
15+
'no_unused_imports' => true,
16+
'not_operator_with_successor_space' => true,
17+
'ordered_imports' => true,
18+
'binary_operator_spaces' => [
19+
'align_equals' => true,
20+
'align_double_arrow' => true,
21+
],
22+
'blank_line_after_namespace' => true,
23+
'blank_line_after_opening_tag' => true,
24+
'blank_line_before_return' => true,
25+
'braces' => true,
26+
'cast_spaces' => true,
27+
'concat_space' => [
28+
'spacing' => 'none',
29+
],
30+
'elseif' => true,
31+
'encoding' => true,
32+
'full_opening_tag' => true,
33+
'function_declaration' => true,
34+
'function_typehint_space' => true,
35+
'include' => true,
36+
'indentation_type' => true,
37+
'line_ending' => true,
38+
'lowercase_constants' => true,
39+
'lowercase_keywords' => true,
40+
'method_argument_space' => true,
41+
'method_separation' => true,
42+
'no_blank_lines_after_class_opening' => true,
43+
'no_blank_lines_after_phpdoc' => true,
44+
'no_closing_tag' => true,
45+
'no_empty_statement' => true,
46+
'no_extra_consecutive_blank_lines' => [
47+
'use',
48+
],
49+
'no_leading_import_slash' => true,
50+
'no_leading_namespace_whitespace' => true,
51+
'no_multiline_whitespace_around_double_arrow' => true,
52+
'no_multiline_whitespace_before_semicolons' => true,
53+
'no_singleline_whitespace_before_semicolons' => true,
54+
'no_spaces_after_function_name' => true,
55+
'no_spaces_inside_parenthesis' => true,
56+
'no_trailing_comma_in_list_call' => true,
57+
'no_trailing_comma_in_singleline_array' => true,
58+
'no_trailing_whitespace' => true,
59+
'no_unused_imports' => true,
60+
'no_whitespace_in_blank_line' => true,
61+
'not_operator_with_successor_space' => true,
62+
'object_operator_without_whitespace' => true,
63+
'phpdoc_align' => true,
64+
'phpdoc_indent' => true,
65+
'phpdoc_inline_tag' => true,
66+
'phpdoc_no_access' => true,
67+
'phpdoc_no_alias_tag' => [
68+
'type' => 'var',
69+
],
70+
'phpdoc_no_package' => true,
71+
'phpdoc_order' => true,
72+
'phpdoc_scalar' => true,
73+
'phpdoc_separation' => true,
74+
'phpdoc_summary' => true,
75+
'phpdoc_to_comment' => true,
76+
'phpdoc_trim' => true,
77+
'phpdoc_var_without_name' => true,
78+
'self_accessor' => true,
79+
'simplified_null_return' => true,
80+
'single_blank_line_at_eof' => true,
81+
'single_blank_line_before_namespace' => true,
82+
'single_import_per_statement' => true,
83+
'single_line_after_imports' => true,
84+
'single_quote' => true,
85+
'standardize_not_equals' => true,
86+
'ternary_operator_spaces' => true,
87+
'trailing_comma_in_multiline_array' => true,
88+
'trim_array_spaces' => true,
89+
'unary_operator_spaces' => true,
90+
'visibility_required' => true,
91+
];
92+
$excludes = [
93+
// add exclude project directory
94+
'vendor',
95+
'node_modules',
96+
];
97+
98+
return Config::create()
99+
->setRules($rules)
100+
->setUsingCache(true)
101+
->setRiskyAllowed(true)
102+
->setFinder(
103+
Finder::create()
104+
->exclude($excludes)
105+
->notName('README.md')
106+
->notName('*.xml')
107+
->notName('*.yml')
108+
);

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
}
2323
},
2424
"extra": {
25+
"branch-alias": {
26+
"dev-master": "1.0-dev"
27+
},
2528
"laravel": {
26-
"providers": []
29+
"providers": ["cesaramirez\\Presets\\Tabler\\TablerPresetServiceProvider"]
2730
}
2831
}
2932
}

src/TablerPreset.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
namespace cesaramirez\Presets\Tabler;
4+
5+
use Illuminate\Container\Container;
6+
use Illuminate\Filesystem\Filesystem;
7+
use Illuminate\Foundation\Console\Presets\Preset;
8+
use Illuminate\Support\Arr;
9+
10+
class TablerPreset extends Preset
11+
{
12+
/**
13+
* Install the preset.
14+
*/
15+
public static function install()
16+
{
17+
static::updatePackages();
18+
static::updateSass();
19+
static::updateBootstrapping();
20+
}
21+
22+
/**
23+
* Install the preset and auth views.
24+
*/
25+
public static function installAuth()
26+
{
27+
static::install();
28+
static::scaffoldAuth();
29+
}
30+
31+
/**
32+
* Update the given package array.
33+
*
34+
* @param array $packages
35+
*
36+
* @return array
37+
*/
38+
protected static function updatePackageArray(array $packages)
39+
{
40+
return [
41+
'bootstrap' => '^4.1.0',
42+
'popper.js' => '^1.14.3',
43+
] + Arr::except($packages, ['bootstrap-sass']);
44+
}
45+
46+
/**
47+
* Update the Sass files for the application.
48+
*/
49+
protected static function updateSass()
50+
{
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'));
55+
}
56+
57+
/**
58+
* Update the bootstrapping files.
59+
*/
60+
protected static function updateBootstrapping()
61+
{
62+
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'));
64+
}
65+
66+
/**
67+
* Export the authentication views.
68+
*/
69+
protected static function scaffoldAuth()
70+
{
71+
file_put_contents(app_path('Http/Controllers/HomeController.php'), static::compileControllerStub());
72+
file_put_contents(
73+
base_path('routes/web.php'),
74+
"\nAuth::routes();\n\nRoute::get('/home', 'HomeController@index')->name('home');\n\n",
75+
FILE_APPEND
76+
);
77+
(new Filesystem())->copyDirectory(__DIR__.'/tabler-stubs/views', resource_path('views'));
78+
}
79+
80+
/**
81+
* Compiles the HomeController stub.
82+
*
83+
* @return string
84+
*/
85+
protected static function compileControllerStub()
86+
{
87+
return str_replace(
88+
'{{namespace}}',
89+
Container::getInstance()->getNamespace(),
90+
file_get_contents(__DIR__.'/tabler-stubs/controllers/HomeController.stub')
91+
);
92+
}
93+
}

src/TablerPresetServiceProvider.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace cesaramirez\Presets\Tabler;
4+
5+
use Illuminate\Foundation\Console\PresetCommand;
6+
use Illuminate\Support\ServiceProvider;
7+
8+
class TablerPresetServiceProvider extends ServiceProvider
9+
{
10+
/**
11+
* Bootstrap the application services.
12+
*/
13+
public function boot()
14+
{
15+
PresetCommand::macro('tabler', function ($command) {
16+
TablerPreset::install();
17+
$command->info('Tabler scaffolding installed successfully.');
18+
$command->info('Please run "yarn && yarn run dev" to compile your fresh scaffolding.');
19+
});
20+
21+
PresetCommand::macro('tabler-auth', function ($command) {
22+
TablerPreset::installAuth();
23+
$command->info('Tabler scaffolding with auth views installed successfully.');
24+
$command->info('Please run "yarn && yarn run dev" to compile your fresh scaffolding.');
25+
});
26+
}
27+
}

src/tabler-stubs/bootstrap.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
window._ = require("lodash");
2+
3+
window.Popper = require("popper.js/dist/umd/popper");
4+
5+
/**
6+
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
7+
* for JavaScript based Bootstrap features such as modals and tabs. This
8+
* code may be modified to fit the specific needs of your application.
9+
*/
10+
11+
try {
12+
window.$ = window.jQuery = require("jquery/dist/jquery.slim");
13+
14+
require("bootstrap");
15+
} catch (e) {}
16+
17+
/**
18+
* We'll load the axios HTTP library which allows us to easily issue requests
19+
* to our Laravel back-end. This library automatically handles sending the
20+
* CSRF token as a header based on the value of the "XSRF" token cookie.
21+
*/
22+
23+
window.axios = require("axios");
24+
25+
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
26+
27+
/**
28+
* Next we will register the CSRF Token as a common header with Axios so that
29+
* all outgoing HTTP requests automatically have it attached. This is just
30+
* a simple convenience so we don't have to attach every token manually.
31+
*/
32+
33+
let token = document.head.querySelector('meta[name="csrf-token"]');
34+
35+
if (token) {
36+
window.axios.defaults.headers.common["X-CSRF-TOKEN"] = token.content;
37+
} else {
38+
console.error(
39+
"CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token"
40+
);
41+
}
42+
43+
/**
44+
* Echo exposes an expressive API for subscribing to channels and listening
45+
* for events that are broadcast by Laravel. Echo and event broadcasting
46+
* allows your team to easily build robust real-time web applications.
47+
*/
48+
49+
// import Echo from 'laravel-echo'
50+
51+
// window.Pusher = require('pusher-js');
52+
53+
// window.Echo = new Echo({
54+
// broadcaster: 'pusher',
55+
// key: 'your-pusher-key',
56+
// cluster: 'mt1',
57+
// encrypted: true
58+
// });
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace {{namespace}}Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class HomeController extends Controller
8+
{
9+
/**
10+
* Create a new controller instance.
11+
*
12+
* @return void
13+
*/
14+
public function __construct()
15+
{
16+
$this->middleware('auth');
17+
}
18+
19+
/**
20+
* Show the application dashboard.
21+
*
22+
* @return \Illuminate\Http\Response
23+
*/
24+
public function index()
25+
{
26+
return view('home');
27+
}
28+
}
Binary file not shown.

0 commit comments

Comments
 (0)