Skip to content

Commit 4be8bd5

Browse files
authored
Merge pull request #4914 from Laravel-Backpack/laravel-v10
Add Laravel 10 Support
2 parents 01e961b + 74d6732 commit 4be8bd5

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
- name: Setup PHP
2525
uses: shivammathur/setup-php@v2
2626
with:
27-
php-version: 8.1
27+
php-version: 8.2
2828
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv, xdebug
2929
coverage: xdebug
3030
tools: composer:v2
3131
- name: Install dependencies
3232
run: |
33-
composer require "laravel/framework:^9.0" "phpunit/phpunit:^9.0" "doctrine/dbal:^3.0" --no-interaction --no-update --no-suggest
33+
composer require "laravel/framework:^10.0" "phpunit/phpunit:^9.0" "doctrine/dbal:^3.0" --no-interaction --no-update --no-suggest
3434
composer update --prefer-dist --no-interaction
3535
- name: Execute tests
3636
run: vendor/bin/phpunit --coverage-clover coverage.xml

.github/workflows/testing.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
# os: [ubuntu-latest, macos-latest, windows-latest]
2222
php: [7.3, 7.4, 8.0, 8.1, 8.2]
2323
dbal: [^2.5, ^3.0]
24-
laravel: [8.*, 9.*]
24+
laravel: [8.*, 9.*, 10.*]
2525
phpunit: [8.*, 9.*]
2626
dependency-version: [stable] # to add: lowest
2727
exclude:
@@ -31,6 +31,17 @@ jobs:
3131
php: 7.4
3232
- laravel: 9.*
3333
phpunit: 8.*
34+
- laravel: 10.*
35+
php: 7.3
36+
- laravel: 10.*
37+
php: 7.4
38+
- laravel: 10.*
39+
php: 8.0
40+
- laravel: 10.*
41+
phpunit: 8.*
42+
- laravel: 10.*
43+
dbal: ^2.5
44+
3445

3546
name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}, PHPUnit ${{ matrix.phpunit }}, DBAL ${{ matrix.dbal }} --prefer-${{ matrix.dependency-version }}
3647

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Start with the ["Introduction" page in our docs](https://backpackforlaravel.com/
8080
## Install
8181

8282
For the current version (recommended):
83-
- [Install Backpack v5 on Laravel 9 or 8](https://backpackforlaravel.com/docs/5.x/installation);
83+
- [Install Backpack v5 on Laravel 10, 9 or 8](https://backpackforlaravel.com/docs/5.x/installation);
8484

8585
For the previous versions (not recommended):
8686
- [Install Backpack 4.1 on Laravel 6, 7 or 8](https://backpackforlaravel.com/docs/4.1/installation) - last feature update was 1st Jan 2021;

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333
],
3434
"require": {
35-
"laravel/framework": "^9.0|^8.69",
35+
"laravel/framework": "^10.0|^9.0|^8.69",
3636
"prologue/alerts": "^1.0|^0.4",
3737
"digitallyhappy/assets": "^2.0.1",
3838
"creativeorange/gravatar": "~1.0",
@@ -43,7 +43,7 @@
4343
"require-dev": {
4444
"phpunit/phpunit": "~8.0|~7.0|~9.0",
4545
"scrutinizer/ocular": "~1.7|~1.1",
46-
"orchestra/testbench": "^7.0|^6.0|^5.0|^4.0|^3.0",
46+
"orchestra/testbench": "^8.0|^7.0|^6.0|^5.0|^4.0|^3.0",
4747
"spatie/laravel-translatable": "^4.0|^5.0|^6.0"
4848
},
4949
"autoload": {

src/app/Console/Commands/Addons/RequireDevTools.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class RequireDevTools extends Command
3030
* @var array
3131
*/
3232
public static $addon = [
33-
'name' => 'DevTools',
33+
'name' => 'DevTools',
3434
'description' => [
3535
'Helps generate models, migrations, operations and CRUDs',
3636
],
37-
'path' => 'vendor/backpack/devtools',
37+
'path' => 'vendor/backpack/devtools',
3838
'command' => 'backpack:require:devtools',
3939
];
4040

@@ -45,6 +45,15 @@ class RequireDevTools extends Command
4545
*/
4646
public function handle()
4747
{
48+
// Prevent installations in laravel 10 as it wouldn't properly work. Waiting for Blueprint L10 support.
49+
if (app()->version() >= 10) {
50+
$this->newLine();
51+
$this->line(sprintf('Support for Laravel 10 is comming soon. Sorry for the trouble.'), 'fg=red');
52+
$this->newLine();
53+
54+
return;
55+
}
56+
4857
// Check if it is installed
4958
if ($this->isInstalled()) {
5059
$this->newLine();

src/app/Models/Traits/HasEnumFields.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ trait HasEnumFields
1515
{
1616
public static function getPossibleEnumValues($field_name)
1717
{
18-
$default_connection = Config::get('database.default');
19-
$table_prefix = Config::get('database.connections.'.$default_connection.'.prefix');
20-
2118
$instance = new static(); // create an instance of the model to be able to get the table name
22-
$connectionName = $instance->getConnectionName();
19+
20+
$connection = $instance->getConnection();
21+
22+
$table_prefix = Config::get('database.connections.'.$connection->getName().'.prefix');
2323

2424
try {
25-
$type = DB::connection($connectionName)->select(DB::raw('SHOW COLUMNS FROM `'.$table_prefix.$instance->getTable().'` WHERE Field = "'.$field_name.'"'))[0]->Type;
25+
$select = app()->version() < 10 ?
26+
DB::raw('SHOW COLUMNS FROM `'.$table_prefix.$instance->getTable().'` WHERE Field = "'.$field_name.'"') :
27+
DB::raw('SHOW COLUMNS FROM `'.$table_prefix.$instance->getTable().'` WHERE Field = "'.$field_name.'"')->getValue($connection->getQueryGrammar());
28+
29+
$type = $connection->select($select)[0]->Type;
2630
} catch (\Exception $e) {
2731
abort(500, 'Enum field type is not supported - it only works on MySQL. Please use select_from_array instead.');
2832
}

0 commit comments

Comments
 (0)