Skip to content

Commit ef613ce

Browse files
Added compatibility with the old version of Laravel on tests
1 parent 80ac64d commit ef613ce

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

testbench.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ laravel: '@testbench'
22

33
providers:
44
- DragonCode\LaravelFeed\LaravelFeedServiceProvider
5+
- Workbench\App\Providers\WorkbenchServiceProvider
56

67
migrations:
78
- workbench/database/migrations

workbench/app/Providers/WorkbenchServiceProvider.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
44

55
namespace Workbench\App\Providers;
66

7+
use Illuminate\Config\Repository;
8+
use Illuminate\Foundation\Application;
9+
use Illuminate\Support\Collection;
710
use Illuminate\Support\ServiceProvider;
11+
use Illuminate\Support\Str;
812

913
class WorkbenchServiceProvider extends ServiceProvider
1014
{
11-
/**
12-
* Register services.
13-
*/
14-
public function register(): void
15+
public function boot(): void
1516
{
16-
//
17+
if ($this->isFreshLaravel()) {
18+
return;
19+
}
20+
21+
Repository::macro('collection', function (string $key) {
22+
return new Collection($this->get($key));
23+
});
1724
}
1825

19-
/**
20-
* Bootstrap services.
21-
*/
22-
public function boot(): void
26+
protected function isFreshLaravel(): bool
2327
{
24-
//
28+
return Str::of(Application::VERSION)->before('.')->toString() === '12';
2529
}
2630
}

0 commit comments

Comments
 (0)