Skip to content

Commit b670266

Browse files
committed
Merge branch 'main' into singleton-view-namespaces
2 parents 32ee90f + 2744e6d commit b670266

22 files changed

+1048
-273
lines changed

.github/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
# branches to consider in the event; optional, defaults to all
77
branches:
88
- 4.1
9-
- v5
9+
- main
1010

1111
jobs:
1212
update_release_draft:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<h3 align="center">Quickly build an admin panel for your Eloquent models, then customize every little detail.</h3>
1111

1212

13+
1314
<p align="center">
1415
<br>
1516
<a href="https://packagist.org/packages/backpack/crud" title="Latest Version on Packagist"><img src="https://img.shields.io/packagist/v/backpack/crud.svg?style=flat-square"></a>

package-lock.json

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"lodash": "^4.17.21",
1717
"pace": "0.0.4",
1818
"resolve-url-loader": "^4.0.0",
19-
"sass": "^1.52.2",
19+
"sass": "^1.54.0",
2020
"sass-loader": "^9.0.3",
21-
"vue-template-compiler": "^2.7.0"
21+
"vue-template-compiler": "^2.7.8"
2222
},
2323
"dependencies": {
2424
"@coreui/coreui": "^2.1.16",
@@ -29,7 +29,7 @@
2929
"bootstrap-datepicker": "^1.9.0",
3030
"bootstrap-daterangepicker": "^3.1.0",
3131
"bootstrap-iconpicker": "^1.8.2",
32-
"ckeditor4": "^4.19.0",
32+
"ckeditor4": "^4.19.1",
3333
"cropperjs": "^1.5.12",
3434
"datatables.net": "^1.12.1",
3535
"datatables.net-bs4": "^1.12.1",

src/BackpackServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class BackpackServiceProvider extends ServiceProvider
2020
\Backpack\CRUD\app\Console\Commands\CreateUser::class,
2121
\Backpack\CRUD\app\Console\Commands\PublishBackpackMiddleware::class,
2222
\Backpack\CRUD\app\Console\Commands\PublishView::class,
23-
\Backpack\CRUD\app\Console\Commands\RequireDevTools::class,
23+
\Backpack\CRUD\app\Console\Commands\Addons\RequireDevTools::class,
24+
\Backpack\CRUD\app\Console\Commands\Addons\RequireEditableColumns::class,
25+
\Backpack\CRUD\app\Console\Commands\Addons\RequirePro::class,
2426
\Backpack\CRUD\app\Console\Commands\Fix::class,
2527
];
2628

src/app/Console/Commands/AddCustomRouteContent.php

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
class AddCustomRouteContent extends Command
1010
{
11+
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
12+
1113
/**
1214
* The name and signature of the console command.
1315
*
@@ -45,32 +47,40 @@ public function handle()
4547
$disk = Storage::disk($disk_name);
4648
$code = $this->argument('code');
4749

48-
if ($disk->exists($path)) {
49-
$old_file_path = $disk->path($path);
50+
$this->progressBlock("Adding route to $path");
5051

51-
// insert the given code before the file's last line
52-
$file_lines = file($old_file_path, FILE_IGNORE_NEW_LINES);
52+
// Validate file exists
53+
if (! $disk->exists($path)) {
54+
Artisan::call('vendor:publish', ['--provider' => \Backpack\CRUD\BackpackServiceProvider::class, '--tag' => 'custom_routes']);
55+
$this->handle();
5356

54-
// if the code already exists in the file, abort
55-
if ($this->getLastLineNumberThatContains($code, $file_lines)) {
56-
return $this->comment('Route already existed.');
57-
}
57+
return;
58+
}
5859

59-
$end_line_number = $this->customRoutesFileEndLine($file_lines);
60-
$file_lines[$end_line_number + 1] = $file_lines[$end_line_number];
61-
$file_lines[$end_line_number] = ' '.$code;
62-
$new_file_content = implode(PHP_EOL, $file_lines);
60+
// insert the given code before the file's last line
61+
$old_file_path = $disk->path($path);
62+
$file_lines = file($old_file_path, FILE_IGNORE_NEW_LINES);
6363

64-
if ($disk->put($path, $new_file_content)) {
65-
$this->info('Successfully added code to '.$path);
66-
} else {
67-
$this->error('Could not write to file: '.$path);
68-
}
69-
} else {
70-
Artisan::call('vendor:publish', ['--provider' => 'Backpack\CRUD\BackpackServiceProvider', '--tag' => 'custom_routes']);
64+
// if the code already exists in the file, abort
65+
if ($this->getLastLineNumberThatContains($code, $file_lines)) {
66+
$this->closeProgressBlock('Already existed', 'yellow');
7167

72-
$this->handle();
68+
return;
7369
}
70+
71+
$end_line_number = $this->customRoutesFileEndLine($file_lines);
72+
$file_lines[$end_line_number + 1] = $file_lines[$end_line_number];
73+
$file_lines[$end_line_number] = ' '.$code;
74+
$new_file_content = implode(PHP_EOL, $file_lines);
75+
76+
if (! $disk->put($path, $new_file_content)) {
77+
$this->errorProgressBlock();
78+
$this->note('Could not write to file.', 'red');
79+
80+
return;
81+
}
82+
83+
$this->closeProgressBlock();
7484
}
7585

7686
private function customRoutesFileEndLine($file_lines)

src/app/Console/Commands/AddSidebarContent.php

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
class AddSidebarContent extends Command
99
{
10+
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
11+
1012
/**
1113
* The name and signature of the console command.
1214
*
@@ -44,22 +46,34 @@ public function handle()
4446
$disk = Storage::disk($disk_name);
4547
$code = $this->argument('code');
4648

47-
if ($disk->exists($path)) {
48-
$contents = $disk->get($path);
49-
$file_lines = file($disk->path($path), FILE_IGNORE_NEW_LINES);
50-
51-
if ($this->getLastLineNumberThatContains($code, $file_lines)) {
52-
return $this->comment('Sidebar item already existed.');
53-
}
54-
55-
if ($disk->put($path, $contents.PHP_EOL.$code)) {
56-
$this->info('Successfully added code to sidebar_content file.');
57-
} else {
58-
$this->error('Could not write to sidebar_content file.');
59-
}
60-
} else {
61-
$this->error('The sidebar_content file does not exist. Make sure Backpack is properly installed.');
49+
$this->progressBlock("Adding sidebar entry to $path");
50+
51+
// Validate file exists
52+
if (! $disk->exists($path)) {
53+
$this->errorProgressBlock();
54+
$this->note('The sidebar_content file does not exist. Make sure Backpack is properly installed.', 'red');
55+
56+
return;
6257
}
58+
59+
$contents = $disk->get($path);
60+
$file_lines = file($disk->path($path), FILE_IGNORE_NEW_LINES);
61+
62+
// Validate the entry already exists
63+
if ($this->getLastLineNumberThatContains($code, $file_lines)) {
64+
$this->closeProgressBlock('Already existed', 'yellow');
65+
66+
return;
67+
}
68+
69+
if (! $disk->put($path, $contents.PHP_EOL.$code)) {
70+
$this->errorProgressBlock();
71+
$this->note('Could not write to sidebar_content file.', 'red');
72+
73+
return;
74+
}
75+
76+
$this->closeProgressBlock();
6377
}
6478

6579
/**
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
namespace Backpack\CRUD\app\Console\Commands\Addons;
4+
5+
use Illuminate\Console\Command;
6+
7+
class RequireDevTools extends Command
8+
{
9+
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
10+
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;
11+
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'backpack:require:devtools
18+
{--debug} : Show process output or not. Useful for debugging.';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Require Backpack DevTools on dev';
26+
27+
/**
28+
* Backpack addons install attribute.
29+
*
30+
* @var array
31+
*/
32+
public static $addon = [
33+
'name' => 'DevTools',
34+
'description' => [
35+
'Helps generate models, migrations, operations and CRUDs',
36+
],
37+
'path' => 'vendor/backpack/devtools',
38+
'command' => 'backpack:require:devtools',
39+
];
40+
41+
/**
42+
* Execute the console command.
43+
*
44+
* @return mixed Command-line output
45+
*/
46+
public function handle()
47+
{
48+
// Check if it is installed
49+
if ($this->isInstalled()) {
50+
$this->newLine();
51+
$this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red');
52+
$this->newLine();
53+
54+
return;
55+
}
56+
57+
$this->newLine();
58+
$this->infoBlock('Connecting to the Backpack add-on repository');
59+
60+
// Check if repositories exists
61+
$this->composerRepositories();
62+
63+
// Check for authentication
64+
$this->checkForAuthentication();
65+
66+
$this->newLine();
67+
$this->progressBlock($this->description);
68+
69+
// Require package
70+
try {
71+
$this->composerRequire('backpack/devtools', ['--dev', '--with-all-dependencies']);
72+
} catch (\Throwable $e) {
73+
$this->errorProgressBlock();
74+
$this->line(' '.$e->getMessage(), 'fg=red');
75+
$this->newLine();
76+
77+
return;
78+
}
79+
80+
// Display general error in case it failed
81+
if (! $this->isInstalled()) {
82+
$this->errorProgressBlock();
83+
$this->note('For further information please check the log file.');
84+
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/addons/');
85+
$this->newLine();
86+
87+
return;
88+
}
89+
90+
// Finish
91+
$this->closeProgressBlock();
92+
$this->newLine();
93+
94+
// manually include the command in the run-time
95+
if (! class_exists(\Backpack\DevTools\Console\Commands\InstallDevTools::class)) {
96+
include base_path('vendor/backpack/devtools/src/Console/Commands/InstallDevTools.php');
97+
}
98+
99+
$this->call(\Backpack\DevTools\Console\Commands\InstallDevTools::class);
100+
}
101+
102+
public function isInstalled()
103+
{
104+
return file_exists(self::$addon['path'].'/composer.json');
105+
}
106+
}

0 commit comments

Comments
 (0)