diff --git a/.gitignore b/.gitignore
index 4e530b36..4e7c0dfd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ composer.lock
resources/assets/minify-manifest.json
resources/assets/open-admin.min.css
resources/assets/open-admin.min.js
+./.phpunit.result.cache
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
new file mode 100644
index 00000000..367f0e02
--- /dev/null
+++ b/DEVELOPMENT.md
@@ -0,0 +1,6 @@
+
+
+```shell
+php vendor/bin/testbench vendor:publish --provider="OpenAdmin\Admin\AdminServiceProvider"
+php vendor/bin/testbench-dusk vendor:publish --provider="OpenAdmin\Admin\AdminServiceProvider"
+```
diff --git a/composer.json b/composer.json
index 1a2c3490..9f0eee8a 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,15 @@
"name": "open-admin-org/open-admin",
"description": "open-admin. Open-source Laravel Admin panel. No pro or paid package, free & open. Based on laravel-admin, with special thanks to z-song",
"type": "library",
- "keywords": ["laravel", "admin", "grid", "form", "open-admin","open","free"],
+ "keywords": [
+ "laravel",
+ "admin",
+ "grid",
+ "form",
+ "open-admin",
+ "open",
+ "free"
+ ],
"homepage": "https://github.com/open-admin-org/open-admin",
"license": "MIT",
"authors": [
@@ -12,17 +20,11 @@
}
],
"require": {
- "php": "~7.3|~8.0",
- "symfony/dom-crawler": "~3.1|~4.0|~5.0",
- "laravel/framework": ">=7.0",
- "doctrine/dbal": "2.*|3.*"
+ "php": ">=8.2"
},
"require-dev": {
- "laravel/laravel": ">=8.0",
- "fzaninotto/faker": "~1.4",
"intervention/image": "~2.3",
- "laravel/browser-kit-testing": "^6.0",
- "spatie/phpunit-watcher": "^1.22.0"
+ "orchestra/testbench-dusk": "^9.0"
},
"autoload": {
"psr-4": {
@@ -34,16 +36,36 @@
},
"autoload-dev": {
"psr-4": {
- "Tests\\Models\\": "tests/models",
- "Tests\\Controllers\\": "tests/controllers"
- },
- "classmap": [
- "tests/TestCase.php"
- ]
+ "Workbench\\App\\": "workbench/app/",
+ "Workbench\\Database\\Factories\\": "workbench/database/factories/",
+ "Workbench\\Database\\Seeders\\": "workbench/database/seeders/",
+ "Tests\\": "tests/"
+ }
},
"scripts": {
- "sass": "sass --watch resources/assets/open-admin/scss/styles.scss:resources/assets/open-admin/css/styles.css resources/assets/open-admin/scss/pages:resources/assets/open-admin/css/pages --style compressed",
- "test": "./vendor/bin/phpunit"
+ "old:sass": "sass --watch resources/assets/open-admin/scss/styles.scss:resources/assets/open-admin/css/styles.css resources/assets/open-admin/scss/pages:resources/assets/open-admin/css/pages --style compressed",
+ "test:feature": "@php vendor/bin/phpunit --testsuite=Feature",
+ "test:browser": "@php vendor/bin/phpunit --testsuite=Browser",
+ "post-autoload-dump": [
+ "@clear",
+ "@prepare",
+ "@dusk:install-chromedriver"
+ ],
+ "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
+ "prepare": "@php vendor/bin/testbench package:discover --ansi",
+ "dusk:install-chromedriver": "@php vendor/bin/dusk-updater detect --auto-update --ansi",
+ "build": "@php vendor/bin/testbench workbench:build --ansi",
+ "serve": [
+ "Composer\\Config::disableProcessTimeout",
+ "@build",
+ "@php vendor/bin/testbench serve"
+ ],
+ "lint": [
+ "@php vendor/bin/phpstan analyse"
+ ],
+ "test": [
+ "@php vendor/bin/phpunit"
+ ]
},
"suggest": {
"intervention/image": "Required to handling and manipulation upload images (~2.3).",
@@ -61,5 +83,6 @@
},
"config": {
"process-timeout": 0
- }
-}
+ },
+ "minimum-stability": "dev"
+}
\ No newline at end of file
diff --git a/database/migrations/2016_01_04_173148_create_admin_tables.php b/database/migrations/2016_01_04_173148_create_admin_tables.php
index 450847ee..069c2edd 100644
--- a/database/migrations/2016_01_04_173148_create_admin_tables.php
+++ b/database/migrations/2016_01_04_173148_create_admin_tables.php
@@ -1,11 +1,12 @@
increments('id');
$table->string('username', 190)->unique();
$table->string('password', 60);
@@ -31,14 +32,14 @@ public function up()
$table->timestamps();
});
- Schema::create(config('admin.database.roles_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.roles_table'), static function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->timestamps();
});
- Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.permissions_table'), static function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
@@ -47,7 +48,7 @@ public function up()
$table->timestamps();
});
- Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.menu_table'), static function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->default(0);
$table->integer('order')->default(0);
@@ -59,35 +60,35 @@ public function up()
$table->timestamps();
});
- Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.role_users_table'), static function (Blueprint $table) {
$table->integer('role_id');
$table->integer('user_id');
$table->index(['role_id', 'user_id']);
$table->timestamps();
});
- Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.role_permissions_table'), static function (Blueprint $table) {
$table->integer('role_id');
$table->integer('permission_id');
$table->index(['role_id', 'permission_id']);
$table->timestamps();
});
- Schema::create(config('admin.database.user_permissions_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.user_permissions_table'), static function (Blueprint $table) {
$table->integer('user_id');
$table->integer('permission_id');
$table->index(['user_id', 'permission_id']);
$table->timestamps();
});
- Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.role_menu_table'), static function (Blueprint $table) {
$table->integer('role_id');
$table->integer('menu_id');
$table->index(['role_id', 'menu_id']);
$table->timestamps();
});
- Schema::create(config('admin.database.operation_log_table'), function (Blueprint $table) {
+ Schema::create(config('admin.database.operation_log_table'), static function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('path');
@@ -104,7 +105,7 @@ public function up()
*
* @return void
*/
- public function down()
+ public function down(): void
{
Schema::dropIfExists(config('admin.database.users_table'));
Schema::dropIfExists(config('admin.database.roles_table'));
@@ -116,4 +117,4 @@ public function down()
Schema::dropIfExists(config('admin.database.role_menu_table'));
Schema::dropIfExists(config('admin.database.operation_log_table'));
}
-}
+};
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index b9440089..2f91f00a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,18 +1,32 @@
-
-
-
- tests/
-
-
-
\ No newline at end of file
+ stopOnError="true"
+>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ./tests/Feature
+
+
+ ./tests/Browser
+
+
+
diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak
new file mode 100644
index 00000000..b9440089
--- /dev/null
+++ b/phpunit.xml.dist.bak
@@ -0,0 +1,18 @@
+
+
+
+
+ tests/
+
+
+
\ No newline at end of file
diff --git a/src/AdminServiceProvider.php b/src/AdminServiceProvider.php
index b5154602..fe39c379 100644
--- a/src/AdminServiceProvider.php
+++ b/src/AdminServiceProvider.php
@@ -6,14 +6,16 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
+use Illuminate\View\Compilers\BladeCompiler;
use OpenAdmin\Admin\Layout\Content;
+use ReflectionClass;
class AdminServiceProvider extends ServiceProvider
{
/**
* @var array
*/
- protected $commands = [
+ protected array $commands = [
Console\AdminCommand::class,
Console\MakeCommand::class,
Console\ControllerCommand::class,
@@ -40,7 +42,7 @@ class AdminServiceProvider extends ServiceProvider
*
* @var array
*/
- protected $routeMiddleware = [
+ protected array $routeMiddleware = [
'admin.auth' => Middleware\Authenticate::class,
'admin.throttle' => Middleware\Throttle::class,
'admin.pjax' => Middleware\Pjax::class,
@@ -55,7 +57,7 @@ class AdminServiceProvider extends ServiceProvider
*
* @var array
*/
- protected $middlewareGroups = [
+ protected array $middlewareGroups = [
'admin' => [
'admin.auth',
'admin.throttle',
@@ -72,7 +74,7 @@ class AdminServiceProvider extends ServiceProvider
*
* @return void
*/
- public function boot()
+ public function boot(): void
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'admin');
@@ -92,7 +94,7 @@ public function boot()
*
* @return void
*/
- protected function ensureHttps()
+ protected function ensureHttps(): void
{
if (config('admin.https') || config('admin.secure')) {
url()->forceScheme('https');
@@ -105,10 +107,10 @@ protected function ensureHttps()
*
* @return void
*/
- protected function registerPublishing()
+ protected function registerPublishing(): void
{
if ($this->app->runningInConsole()) {
- $this->publishes([__DIR__.'/../config' => config_path()], 'open-admin-config');
+ $this->publishes([__DIR__.'/../config/admin.php' => config_path('admin.php')], 'open-admin-config');
$this->publishes([__DIR__.'/../resources/lang' => resource_path('lang')], 'open-admin-lang');
$this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'open-admin-migrations');
$this->publishes([__DIR__.'/../resources/assets' => public_path('vendor/open-admin')], 'open-admin-assets');
@@ -121,9 +123,9 @@ protected function registerPublishing()
*
* @return void
*/
- protected function compatibleBlade()
+ protected function compatibleBlade(): void
{
- $reflectionClass = new \ReflectionClass('\Illuminate\View\Compilers\BladeCompiler');
+ $reflectionClass = new ReflectionClass(BladeCompiler::class);
if ($reflectionClass->hasMethod('withoutDoubleEncoding')) {
Blade::withoutDoubleEncoding();
@@ -133,7 +135,7 @@ protected function compatibleBlade()
/**
* Extends laravel router.
*/
- protected function macroRouter()
+ protected function macroRouter(): void
{
Router::macro('content', function ($uri, $content, $options = []) {
return $this->match(['GET', 'HEAD'], $uri, function (Content $layout) use ($content, $options) {
@@ -159,8 +161,9 @@ protected function macroRouter()
*
* @return void
*/
- public function register()
+ public function register(): void
{
+ $this->mergeConfigFrom(__DIR__.'/../config/admin.php', 'admin');
$this->loadAdminAuthConfig();
$this->registerRouteMiddleware();
@@ -175,7 +178,7 @@ public function register()
*
* @return void
*/
- protected function loadAdminAuthConfig()
+ protected function loadAdminAuthConfig(): void
{
config(Arr::dot(config('admin.auth', []), 'auth.'));
}
@@ -185,7 +188,7 @@ protected function loadAdminAuthConfig()
*
* @return void
*/
- protected function registerRouteMiddleware()
+ protected function registerRouteMiddleware(): void
{
// register route middleware.
foreach ($this->routeMiddleware as $key => $middleware) {
@@ -203,13 +206,13 @@ protected function registerRouteMiddleware()
*
* @return void
*/
- public function bladeDirectives()
+ public function bladeDirectives(): void
{
- Blade::directive('box', function ($title) {
- return "render(); ?>";
});
}
diff --git a/src/Console/stubs/routes.stub b/src/Console/stubs/routes.stub
index 81d42218..49090d7c 100644
--- a/src/Console/stubs/routes.stub
+++ b/src/Console/stubs/routes.stub
@@ -1,16 +1,19 @@
config('admin.route.prefix'),
- 'namespace' => config('admin.route.namespace'),
- 'middleware' => config('admin.route.middleware'),
- 'as' => config('admin.route.prefix') . '.',
-], function (Router $router) {
-
- $router->get('/', 'HomeController@index')->name('home');
-
+ 'prefix' => config('admin.route.prefix'),
+ 'namespace' => config('admin.route.namespace'),
+ 'middleware' => config('admin.route.middleware'),
+ 'as' => config('admin.route.prefix').'.',
+], static function (Router $router) {
+ $router->get('/', [HomeController::class, 'index'])->name('home');
});
diff --git a/testbench.yaml b/testbench.yaml
new file mode 100644
index 00000000..08cd9fbd
--- /dev/null
+++ b/testbench.yaml
@@ -0,0 +1,25 @@
+#laravel: vendor/orchestra/testbench-core/laravel
+
+providers:
+ - OpenAdmin\Admin\AdminServiceProvider
+ - Workbench\App\Providers\WorkbenchServiceProvider
+
+migrations:
+ - database/migrations
+ - workbench/database/migrations
+
+seeders:
+ - Workbench\Database\Seeders\DatabaseSeeder
+
+workbench:
+ start: '/'
+ install: true
+ discovers:
+ web: true
+ api: false
+ commands: false
+ components: false
+ views: false
+ build: []
+ assets: []
+ sync: []
diff --git a/tests/AuthTest.php b/tests/AuthTest.php
deleted file mode 100644
index 3b491ff4..00000000
--- a/tests/AuthTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-visit('admin/auth/login')
- ->see('login');
- }
-
- public function testVisitWithoutLogin()
- {
- $this->visit('admin')
- ->dontSeeIsAuthenticated('admin')
- ->seePageIs('admin/auth/login');
- }
-
- public function testLogin()
- {
- $credentials = ['username' => 'admin', 'password' => 'admin'];
-
- $this->visit('admin/auth/login')
- ->see('login')
- ->submitForm('Login', $credentials)
- ->see('dashboard')
- ->seeCredentials($credentials, 'admin')
- ->seeIsAuthenticated('admin')
- ->seePageIs('admin')
- ->see('Dashboard')
- ->see('Description...')
-
- ->see('Environment')
- ->see('PHP version')
- ->see('Laravel version')
-
- ->see('Available extensions')
- ->seeLink('open-admin-ext/helpers', 'https://github.com/open-admin-extensions/helpers')
- ->seeLink('open-admin-ext/backup', 'https://github.com/open-admin-extensions/backup')
- ->seeLink('open-admin-ext/media-manager', 'https://github.com/open-admin-extensions/media-manager')
-
- ->see('Dependencies')
- ->see('php')
-// ->see('>=7.0.0')
- ->see('laravel/framework');
-
- $this
- ->see('Admin')
- ->see('Users')
- ->see('Roles')
- ->see('Permission')
- ->see('Operation log')
- ->see('Menu');
- }
-
- public function testLogout()
- {
- $this->visit('admin/auth/logout')
- ->seePageIs('admin/auth/login')
- ->dontSeeIsAuthenticated('admin');
- }
-}
diff --git a/tests/Browser/AuthTest.php b/tests/Browser/AuthTest.php
new file mode 100644
index 00000000..c6366940
--- /dev/null
+++ b/tests/Browser/AuthTest.php
@@ -0,0 +1,67 @@
+browse(function (Browser $browser) {
+ $browser->visit('admin/auth/login')
+ ->assertSee('Login');
+ });
+ }
+
+ public function testVisitWithoutLogin(): void
+ {
+ $this->browse(function (Browser $browser) {
+ $browser->visit('admin')
+ ->assertGuest()
+ ->assertPathIs('/admin/auth/login');
+ });
+ }
+
+ public function testLogin()
+ {
+ $this->browse(function (Browser $browser) {
+ $browser->visit('admin/auth/login')
+ ->assertSee('Login')
+ ->type('username', 'admin')
+ ->type('password', 'admin')
+ ->press('Login')
+ ->assertSee('Dashboard')
+ ->assertAuthenticated('admin')
+ ->assertPathIs('/admin')
+ ->assertSee('Dashboard')
+ ->assertSee('Description...')
+ ->assertSee('Environment')
+ ->assertSee('PHP version')
+ ->assertSee('Laravel version')
+ ->assertSee('Available extensions')
+ ->assertSeeLink('open-admin-ext/helpers', 'https://github.com/open-admin-extensions/helpers')
+ ->assertSeeLink('open-admin-ext/backup', 'https://github.com/open-admin-extensions/backup')
+ ->assertSeeLink('open-admin-ext/media-manager', 'https://github.com/open-admin-extensions/media-manager')
+ ->assertSee('Dependencies')
+ ->assertSee('laravel/framework')
+ ->assertSee('Admin')
+ ->click("li.treeview > a.has-subs")
+ ->assertSeeLink( 'Users')
+ ->assertSeeLink('Roles')
+ ->assertSeeLink('Permission')
+ ->assertSeeLink('Menu')
+ ->assertSeeLink('Operation log');
+ });
+ }
+
+ public function testLogout(): void
+ {
+ $this->browse(function (Browser $browser) {
+ $browser->visit('admin/auth/logout')
+ ->assertPathIs('/admin/auth/login')
+ ->assertGuest();
+ });
+ }
+}
diff --git a/tests/FileUploadTest.php b/tests/Browser/FileUploadTest.php
similarity index 76%
rename from tests/FileUploadTest.php
rename to tests/Browser/FileUploadTest.php
index 947fb130..1f0e5af2 100644
--- a/tests/FileUploadTest.php
+++ b/tests/Browser/FileUploadTest.php
@@ -1,10 +1,15 @@
be(Administrator::first(), 'admin');
}
- public function testFileUploadPage()
+ public function testFileUploadPage(): void
{
- $this->visit('admin/files/create')
- ->see('Files')
- ->seeInElement('h3[class=box-title]', 'Create')
- ->seeElement('input[name=file1]')
- ->seeElement('input[name=file2]')
- ->seeElement('input[name=file3]')
- ->seeElement('input[name=file4]')
- ->seeElement('input[name=file5]')
- ->seeElement('input[name=file6]')
-// ->seeInElement('a[href="/admin/files"]', 'List')
- ->seeInElement('button[type=reset]', 'Reset')
- ->seeInElement('button[type=submit]', 'Submit');
+ $this->browse(function (Browser $browser) {
+ $browser->visit('admin/files/create')
+ ->assertSee('Files')
+ ->assertSeeIn('h3[class=box-title]', 'Create')
+ ->assertSeeAnythingIn('input[name=file1]')
+ ->assertSeeAnythingIn('input[name=file2]')
+ ->assertSeeAnythingIn('input[name=file3]')
+ ->assertSeeAnythingIn('input[name=file4]')
+ ->assertSeeAnythingIn('input[name=file5]')
+ ->assertSeeAnythingIn('input[name=file6]')
+ // ->assertSeeIn('a[href="/admin/files"]', 'List')
+ ->assertSeeIn('button[type=reset]', 'Reset')
+ ->assertSeeIn('button[type=submit]', 'Submit');
+ });
}
protected function uploadFiles()
@@ -52,9 +59,9 @@ public function testUploadFile()
$where = [
'file1' => 'files/AuthTest.php',
- 'file2' => 'files/InstallTest.php',
- 'file3' => 'files/IndexTest.php',
- 'file4' => 'files/LaravelTest.php',
+ 'file2' => 'files/Tests\Browser\InstallTest.php',
+ 'file3' => 'files/Tests\Browser\IndexTest.php',
+ 'file4' => 'files/Tests\Browser\LaravelTest.php',
'file5' => 'files/routes.php',
'file6' => 'files/2016_11_22_093148_create_test_tables.php',
];
@@ -88,7 +95,7 @@ public function testUpdateFile()
->seeElement('input[name=file4]')
->seeElement('input[name=file5]')
->seeElement('input[name=file6]')
-// ->seeInElement('a[href="/admin/files"]', 'List')
+ // ->seeInElement('a[href="/admin/files"]', 'List')
->seeInElement('button[type=reset]', 'Reset')
->seeInElement('button[type=submit]', 'Submit');
diff --git a/tests/ImageUploadTest.php b/tests/Browser/ImageUploadTest.php
similarity index 96%
rename from tests/ImageUploadTest.php
rename to tests/Browser/ImageUploadTest.php
index d96f6ee7..57d39173 100644
--- a/tests/ImageUploadTest.php
+++ b/tests/Browser/ImageUploadTest.php
@@ -1,11 +1,15 @@
array_pad([], $size, $file)];
$this->call(
@@ -212,7 +216,7 @@ public function testRemoveMultipleFiles()
$file = new \Illuminate\Http\UploadedFile($path, 'test.jpg', 'image/jpeg', null, true);
- $size = rand(10, 20);
+ $size = rand(10, 20);
$files = ['pictures' => array_pad([], $size, $file)];
$this->call(
diff --git a/tests/IndexTest.php b/tests/Browser/IndexTest.php
similarity index 91%
rename from tests/IndexTest.php
rename to tests/Browser/IndexTest.php
index 6ff03b04..c126be57 100644
--- a/tests/IndexTest.php
+++ b/tests/Browser/IndexTest.php
@@ -1,8 +1,11 @@
visit('admin/')
->see('Dashboard')
->see('Description...')
-
->see('Environment')
->see('PHP version')
->see('Laravel version')
-
->see('Available extensions')
->seeLink('open-admin-ext/helpers', 'https://github.com/open-admin-extensions/helpers')
->seeLink('open-admin-ext/backup', 'https://github.com/open-admin-extensions/backup')
->seeLink('open-admin-ext/media-manager', 'https://github.com/open-admin-extensions/media-manager')
-
->see('Dependencies')
->see('php')
-// ->see('>=7.0.0')
+ // ->see('>=7.0.0')
->see('laravel/framework');
}
diff --git a/tests/InstallTest.php b/tests/Browser/InstallTest.php
similarity index 88%
rename from tests/InstallTest.php
rename to tests/Browser/InstallTest.php
index ec451562..62b821d7 100644
--- a/tests/InstallTest.php
+++ b/tests/Browser/InstallTest.php
@@ -1,6 +1,10 @@
seeInDatabase(config('admin.database.menu_table'), $item)
->assertEquals(8, Menu::count());
-// $this->expectException(\Laravel\BrowserKitTesting\HttpException::class);
-//
-// $this->visit('admin')
-// ->see('Test')
-// ->click('Test');
+ // $this->expectException(\Laravel\BrowserKitTesting\HttpException::class);
+ //
+ // $this->visit('admin')
+ // ->see('Test')
+ // ->click('Test');
}
public function testDeleteMenu()
diff --git a/tests/ModelTreeTest.php b/tests/Browser/ModelTreeTest.php
similarity index 79%
rename from tests/ModelTreeTest.php
rename to tests/Browser/ModelTreeTest.php
index 0bed689b..8afea80e 100644
--- a/tests/ModelTreeTest.php
+++ b/tests/Browser/ModelTreeTest.php
@@ -1,8 +1,11 @@
notSeeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
->notSeeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
->notSeeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET'])
-
->assertEquals(0, OperationLog::count());
}
}
diff --git a/tests/PermissionsTest.php b/tests/Browser/PermissionsTest.php
similarity index 96%
rename from tests/PermissionsTest.php
rename to tests/Browser/PermissionsTest.php
index e31b4724..10c16f55 100644
--- a/tests/PermissionsTest.php
+++ b/tests/Browser/PermissionsTest.php
@@ -1,10 +1,13 @@
see('Permissions')
->submitForm('Submit', ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => 'users/1', 'http_method' => ['DELETE']])
->seePageIs('admin/auth/permissions')
- ->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => 'users/1/edit', 'http_method' => 'GET'])
- ->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => 'users/1', 'http_method' => 'DELETE'])
+ ->seeInDatabase(config('admin.database.permissions_table'),
+ ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => 'users/1/edit', 'http_method' => 'GET'])
+ ->seeInDatabase(config('admin.database.permissions_table'),
+ ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => 'users/1', 'http_method' => 'DELETE'])
->assertEquals(7, Permission::count());
$this->assertTrue(Administrator::first()->can('can-edit'));
diff --git a/tests/RolesTest.php b/tests/Browser/RolesTest.php
similarity index 97%
rename from tests/RolesTest.php
rename to tests/Browser/RolesTest.php
index e3f359c0..b15e788d 100644
--- a/tests/RolesTest.php
+++ b/tests/Browser/RolesTest.php
@@ -1,9 +1,12 @@
'123456',
'password_confirmation' => '123456',
//"avatar" => "test.jpg",
- 'profile' => [
+ 'profile' => [
'first_name' => 'John',
'last_name' => 'Doe',
'postcode' => '123456',
@@ -61,7 +66,6 @@ public function testSubmitForm()
$this->visit('admin/users/create')
->attach(__DIR__.'/assets/test.jpg', 'avatar')
-
->submitForm('Submit', $data)
->seePageIs('admin/users')
->seeInElement('td', 1)
@@ -101,11 +105,11 @@ public function testSubmitForm()
protected function seedsTable($count = 100)
{
- factory(\Tests\Models\User::class, $count)
+ factory(\Workbench\App\Models\User::class, $count)
->create()
->each(function ($u) {
- $u->profile()->save(factory(\Tests\Models\Profile::class)->make());
- $u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
+ $u->profile()->save(factory(\Workbench\App\Models\Profile::class)->make());
+ $u->tags()->saveMany(factory(\Workbench\App\Models\Tag::class, 5)->make());
});
}
diff --git a/tests/UserGridTest.php b/tests/Browser/UserGridTest.php
similarity index 92%
rename from tests/UserGridTest.php
rename to tests/Browser/UserGridTest.php
index b4694be3..95f01d85 100644
--- a/tests/UserGridTest.php
+++ b/tests/Browser/UserGridTest.php
@@ -1,10 +1,15 @@
create()
->each(function ($u) {
- $u->profile()->save(factory(\Tests\Models\Profile::class)->make());
- $u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
+ $u->profile()->save(factory(\Workbench\App\Models\Profile::class)->make());
+ $u->tags()->saveMany(factory(\Workbench\App\Models\Tag::class, 5)->make());
$u->data = ['json' => ['field' => random_int(0, 50)]];
$u->save();
});
@@ -193,11 +198,11 @@ public function testDisplayCallback()
public function testHasManyRelation()
{
- factory(\Tests\Models\User::class, 10)
+ factory(\Workbench\App\Models\User::class, 10)
->create()
->each(function ($u) {
- $u->profile()->save(factory(\Tests\Models\Profile::class)->make());
- $u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
+ $u->profile()->save(factory(\Workbench\App\Models\Profile::class)->make());
+ $u->tags()->saveMany(factory(\Workbench\App\Models\Tag::class, 5)->make());
});
$this->visit('admin/users')
diff --git a/tests/UserSettingTest.php b/tests/Browser/UserSettingTest.php
similarity index 96%
rename from tests/UserSettingTest.php
rename to tests/Browser/UserSettingTest.php
index 5d7fbfa0..7dffdb7a 100644
--- a/tests/UserSettingTest.php
+++ b/tests/Browser/UserSettingTest.php
@@ -1,9 +1,12 @@
booting(function () {
- $loader = \Illuminate\Foundation\AliasLoader::getInstance();
- $loader->alias('Admin', \OpenAdmin\Admin\Facades\Admin::class);
- });
-
- $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
-
- $app->register('OpenAdmin\Admin\AdminServiceProvider');
-
- return $app;
- }
-
- protected function setUp(): void
- {
- parent::setUp();
-
- $adminConfig = require __DIR__.'/config/admin.php';
-
- $this->app['config']->set('database.default', env('DB_CONNECTION', 'mysql'));
- $this->app['config']->set('database.connections.mysql.host', env('MYSQL_HOST', 'localhost'));
- $this->app['config']->set('database.connections.mysql.database', env('MYSQL_DATABASE', 'laravel_admin_test'));
- $this->app['config']->set('database.connections.mysql.username', env('MYSQL_USER', 'root'));
- $this->app['config']->set('database.connections.mysql.password', env('MYSQL_PASSWORD', ''));
- $this->app['config']->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF');
- $this->app['config']->set('filesystems', require __DIR__.'/config/filesystems.php');
- $this->app['config']->set('admin', $adminConfig);
-
- foreach (Arr::dot(Arr::get($adminConfig, 'auth'), 'auth.') as $key => $value) {
- $this->app['config']->set($key, $value);
- }
-
- $this->artisan('vendor:publish', ['--provider' => 'OpenAdmin\Admin\AdminServiceProvider']);
-
- Schema::defaultStringLength(191);
-
- $this->artisan('admin:install');
+namespace Tests;
- $this->migrateTestTables();
-
- if (file_exists($routes = admin_path('routes.php'))) {
- require $routes;
- }
-
- require __DIR__.'/routes.php';
-
- require __DIR__.'/seeds/factory.php';
-
-// \OpenAdmin\Admin\Admin::$css = [];
-// \OpenAdmin\Admin\Admin::$js = [];
-// \OpenAdmin\Admin\Admin::$script = [];
- }
-
- protected function tearDown(): void
- {
- (new CreateAdminTables())->down();
-
- (new CreateTestTables())->down();
-
- DB::select("delete from `migrations` where `migration` = '2016_01_04_173148_create_admin_tables'");
-
- parent::tearDown();
- }
-
- /**
- * run package database migrations.
- *
- * @return void
- */
- public function migrateTestTables()
- {
- $fileSystem = new Filesystem();
-
- $fileSystem->requireOnce(__DIR__.'/migrations/2016_11_22_093148_create_test_tables.php');
-
- (new CreateTestTables())->up();
- }
+class TestCase extends \Orchestra\Testbench\TestCase
+{
+ use TestCaseTrait;
}
diff --git a/tests/TestCaseTrait.php b/tests/TestCaseTrait.php
new file mode 100644
index 00000000..1a7f2efb
--- /dev/null
+++ b/tests/TestCaseTrait.php
@@ -0,0 +1,71 @@
+ Admin::class,
+ ];
+ }
+
+ public function ignorePackageDiscoveriesFrom(): array
+ {
+ return [];
+ }
+
+ protected function defineDatabaseMigrations(): void
+ {
+ $this->loadMigrationsFrom(workbench_path('database/migrations'));
+ }
+
+ protected function defineEnvironment($app): void
+ {
+ tap($app['config'], $this->setupConfig());
+ }
+
+ protected function setUp(): void
+ {
+ parent::setUp();
+
+ $setupConfig = $this->setupConfig();
+ $this->beforeServingApplication(fn (Application $app, Repository $config) => $setupConfig($config));
+ }
+
+ protected function setupConfig(): callable
+ {
+ return static function (Repository $config) {
+ $config->set('filesystems.disks.admin', [
+ 'driver' => 'local',
+ 'root' => public_path('uploads'),
+ 'visibility' => 'public',
+ 'url' => 'http://localhost:8000/uploads/',
+ ]);
+ $config->set('admin.auth.controller', AuthController::class);
+ $config->set('admin.directory', __DIR__.'/../workbench/app/Admin');
+ $config->set('admin.bootstrap', __DIR__.'/../workbench/app/Admin/bootstrap.php');
+ };
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 00000000..7bb53d97
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,12 @@
+ 'Open-admin',
-
- /*
- * Logo in admin panel header.
- */
- 'logo' => 'Laravel admin',
-
- /*
- * Mini-logo in admin panel header.
- */
- 'logo-mini' => 'La',
-
- /*
- * Route configuration.
- */
- 'route' => [
-
- 'prefix' => 'admin',
-
- 'namespace' => 'App\\Admin\\Controllers',
-
- 'middleware' => ['web', 'admin'],
- ],
-
- /*
- * Open-admin install directory.
- */
- 'directory' => app_path('Admin'),
-
- /*
- * Open-admin html title.
- */
- 'title' => 'Admin',
-
- /*
- * Use `https`.
- */
- 'secure' => false,
-
- /*
- * Open-admin auth setting.
- */
- 'auth' => [
- 'guards' => [
- 'admin' => [
- 'driver' => 'session',
- 'provider' => 'admin',
- ],
- ],
-
- 'providers' => [
- 'admin' => [
- 'driver' => 'eloquent',
- 'model' => OpenAdmin\Admin\Auth\Database\Administrator::class,
- ],
- ],
- ],
-
- /*
- * Open-admin upload setting.
- */
- 'upload' => [
-
- 'disk' => 'admin',
-
- 'directory' => [
- 'image' => 'images',
- 'file' => 'files',
- ],
- ],
-
- /*
- * Open-admin database setting.
- */
- 'database' => [
-
- // Database connection for following tables.
- 'connection' => '',
-
- // User tables and model.
- 'users_table' => 'admin_users',
- 'users_model' => OpenAdmin\Admin\Auth\Database\Administrator::class,
-
- // Role table and model.
- 'roles_table' => 'admin_roles',
- 'roles_model' => OpenAdmin\Admin\Auth\Database\Role::class,
-
- // Permission table and model.
- 'permissions_table' => 'admin_permissions',
- 'permissions_model' => OpenAdmin\Admin\Auth\Database\Permission::class,
-
- // Menu table and model.
- 'menu_table' => 'admin_menu',
- 'menu_model' => OpenAdmin\Admin\Auth\Database\Menu::class,
-
- // Pivot table for table above.
- 'operation_log_table' => 'admin_operation_log',
- 'user_permissions_table' => 'admin_user_permissions',
- 'role_users_table' => 'admin_role_users',
- 'role_permissions_table' => 'admin_role_permissions',
- 'role_menu_table' => 'admin_role_menu',
- ],
-
- /*
- * By setting this option to open or close operation log in open-admin.
- */
- 'operation_log' => [
-
- 'enable' => true,
-
- /*
- * Routes that will not log to database.
- *
- * All method to path like: admin/auth/logs
- * or specific method to path like: get:admin/auth/logs
- */
- 'except' => [
- 'admin/auth/logs*',
- ],
- ],
-
- /*
- * @see https://adminlte.io/docs/2.4/layout
- */
- 'skin' => 'skin-blue-light',
-
- /*
- |---------------------------------------------------------|
- |LAYOUT OPTIONS | fixed |
- | | layout-boxed |
- | | layout-top-nav |
- | | sidebar-collapse |
- | | sidebar-mini |
- |---------------------------------------------------------|
- */
- 'layout' => ['sidebar-mini', 'sidebar-collapse'],
-
- /*
- * Version displayed in footer.
- */
- 'version' => '1.5.x-dev',
-
- /*
- * Settings for extensions.
- */
- 'extensions' => [
-
- ],
-];
diff --git a/tests/config/filesystems.php b/tests/config/filesystems.php
deleted file mode 100644
index 3cd874e8..00000000
--- a/tests/config/filesystems.php
+++ /dev/null
@@ -1,95 +0,0 @@
- 'public',
-
- /*
- |--------------------------------------------------------------------------
- | Default Cloud Filesystem Disk
- |--------------------------------------------------------------------------
- |
- | Many applications store files both locally and in the cloud. For this
- | reason, you may specify a default "cloud" driver here. This driver
- | will be bound as the Cloud disk implementation in the container.
- |
- */
-
- 'cloud' => 's3',
-
- /*
- |--------------------------------------------------------------------------
- | Filesystem Disks
- |--------------------------------------------------------------------------
- |
- | Here you may configure as many filesystem "disks" as you wish, and you
- | may even configure multiple disks of the same driver. Defaults have
- | been setup for each driver as an example of the required options.
- |
- */
-
- 'disks' => [
-
- 'local' => [
- 'driver' => 'local',
- 'root' => storage_path('app'),
- ],
-
- 'public' => [
- 'driver' => 'local',
- 'root' => storage_path('app/public'),
- 'visibility' => 'public',
- ],
-
- 's3' => [
- 'driver' => 's3',
- 'key' => 'your-key',
- 'secret' => 'your-secret',
- 'region' => 'your-region',
- 'bucket' => 'your-bucket',
- ],
-
- 'admin' => [
- 'driver' => 'local',
- 'root' => public_path('uploads'),
- 'visibility' => 'public',
- 'url' => 'http://localhost:8000/uploads/',
- ],
-
- 'qiniu' => [
- 'driver' => 'qiniu',
- 'domains' => [
- 'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名
- 'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名
- 'custom' => 'static.abc.com', //你的自定义域名
- ],
- 'access_key' => 'tIyz5h5IDT1-PQS22iRrI4dCBEktWj76O-ls856K', //AccessKey
- 'secret_key' => 'TCU2GuSlbzxKgnixYO_-pdo4odbXttm1RNNvEwSD', //SecretKey
- 'bucket' => 'laravel', //Bucket名字
- 'notify_url' => '', //持久化处理回调地址
- ],
-
- 'aliyun' => [
- 'driver' => 'oss',
- 'access_id' => 'LTAIsOQNIDQN78Jr',
- 'access_key' => 'ChsYewaCxm1mi7AIBPRniuncEbFHNO',
- 'bucket' => 'open-admin',
- 'endpoint' => 'oss-cn-shanghai.aliyuncs.com',
- ],
-
- ],
-
-];
diff --git a/tests/models/Profile.php b/tests/models/Profile.php
deleted file mode 100644
index d99b6705..00000000
--- a/tests/models/Profile.php
+++ /dev/null
@@ -1,15 +0,0 @@
-belongsTo(User::class, 'user_id');
- }
-}
diff --git a/tests/models/Tag.php b/tests/models/Tag.php
deleted file mode 100644
index 6750cd28..00000000
--- a/tests/models/Tag.php
+++ /dev/null
@@ -1,15 +0,0 @@
-belongsToMany(User::class, 'test_user_tags', 'tag_id', 'user_id');
- }
-}
diff --git a/tests/models/User.php b/tests/models/User.php
deleted file mode 100644
index 56fe4adc..00000000
--- a/tests/models/User.php
+++ /dev/null
@@ -1,34 +0,0 @@
- 'array'];
-
- public function profile()
- {
- return $this->hasOne(Profile::class, 'user_id');
- }
-
- public function getFullNameAttribute()
- {
- return "{$this->profile['first_name']} {$this->profile['last_name']}";
- }
-
- public function getPositionAttribute()
- {
- return "{$this->profile->latitude} {$this->profile->longitude}";
- }
-
- public function tags()
- {
- return $this->belongsToMany(Tag::class, 'test_user_tags', 'user_id', 'tag_id');
- }
-}
diff --git a/tests/routes.php b/tests/routes.php
deleted file mode 100644
index 4a8af187..00000000
--- a/tests/routes.php
+++ /dev/null
@@ -1,12 +0,0 @@
- config('admin.route.prefix'),
- 'namespace' => 'Tests\Controllers',
- 'middleware' => ['web', 'admin'],
-], function ($router) {
- $router->resource('images', ImageController::class);
- $router->resource('multiple-images', MultipleImageController::class);
- $router->resource('files', FileController::class);
- $router->resource('users', UserController::class);
-});
diff --git a/tests/seeds/UserTableSeeder.php b/tests/seeds/UserTableSeeder.php
deleted file mode 100644
index c5dfe4df..00000000
--- a/tests/seeds/UserTableSeeder.php
+++ /dev/null
@@ -1,19 +0,0 @@
-create()
- ->each(function ($u) {
- $u->profile()->save(factory(\Tests\Models\Profile::class)->make());
- $u->tags()->saveMany(factory(\Tests\Models\Tag::class, 5)->make());
- $u->data = ['json' => ['field' => random_int(0, 50)]];
- });
- }
-}
diff --git a/tests/seeds/factory.php b/tests/seeds/factory.php
deleted file mode 100644
index c1b9245c..00000000
--- a/tests/seeds/factory.php
+++ /dev/null
@@ -1,36 +0,0 @@
-define(Tests\Models\User::class, function (Faker $faker) {
- return [
- 'username' => $faker->userName,
- 'email' => $faker->email,
- 'mobile' => $faker->phoneNumber,
- 'avatar' => $faker->imageUrl(),
- 'password' => '$2y$10$U2WSLymU6eKJclK06glaF.Gj3Sw/ieDE3n7mJYjKEgDh4nzUiSESO', // bcrypt(123456)
- ];
-});
-
-$factory->define(Tests\Models\Profile::class, function (Faker $faker) {
- return [
- 'first_name' => $faker->firstName,
- 'last_name' => $faker->lastName,
- 'postcode' => $faker->postcode,
- 'address' => $faker->address,
- 'latitude' => $faker->latitude,
- 'longitude' => $faker->longitude,
- 'color' => $faker->hexColor,
- 'start_at' => $faker->dateTime,
- 'end_at' => $faker->dateTime,
- ];
-});
-
-$factory->define(Tests\Models\Tag::class, function (Faker $faker) {
- return [
- 'name' => $faker->word,
- ];
-});
diff --git a/workbench/.gitignore b/workbench/.gitignore
new file mode 100644
index 00000000..72603218
--- /dev/null
+++ b/workbench/.gitignore
@@ -0,0 +1,2 @@
+.env
+.env.dusk
diff --git a/workbench/app/Admin/Controllers/AuthController.php b/workbench/app/Admin/Controllers/AuthController.php
new file mode 100644
index 00000000..ca9e8524
--- /dev/null
+++ b/workbench/app/Admin/Controllers/AuthController.php
@@ -0,0 +1,11 @@
+column('id', __('ID'))->sortable();
+ $grid->column('created_at', __('Created at'));
+ $grid->column('updated_at', __('Updated at'));
+
+ return $grid;
+ }
+
+ /**
+ * Make a show builder.
+ *
+ * @param mixed $id
+ * @return Show
+ */
+ protected function detail($id)
+ {
+ $show = new Show(ExampleModel::findOrFail($id));
+
+ $show->field('id', __('ID'));
+ $show->field('created_at', __('Created at'));
+ $show->field('updated_at', __('Updated at'));
+
+ return $show;
+ }
+
+ /**
+ * Make a form builder.
+ *
+ * @return Form
+ */
+ protected function form()
+ {
+ $form = new Form(new ExampleModel);
+
+ $form->display('id', __('ID'));
+ $form->display('created_at', __('Created At'));
+ $form->display('updated_at', __('Updated At'));
+
+ return $form;
+ }
+}
diff --git a/workbench/app/Admin/Controllers/HomeController.php b/workbench/app/Admin/Controllers/HomeController.php
new file mode 100644
index 00000000..441bd27c
--- /dev/null
+++ b/workbench/app/Admin/Controllers/HomeController.php
@@ -0,0 +1,37 @@
+css_file(Admin::asset("open-admin/css/pages/dashboard.css"))
+ ->title('Dashboard')
+ ->description('Description...')
+ ->row(Dashboard::title())
+ ->row(function (Row $row) {
+ $row->column(4, function (Column $column) {
+ $column->append(Dashboard::environment());
+ });
+
+ $row->column(4, function (Column $column) {
+ $column->append(Dashboard::extensions());
+ });
+
+ $row->column(4, function (Column $column) {
+ $column->append(Dashboard::dependencies());
+ });
+ });
+ }
+}
diff --git a/workbench/app/Admin/bootstrap.php b/workbench/app/Admin/bootstrap.php
new file mode 100644
index 00000000..8816a2e8
--- /dev/null
+++ b/workbench/app/Admin/bootstrap.php
@@ -0,0 +1,24 @@
+
+ *
+ * Bootstraper for Admin.
+ *
+ * Here you can remove builtin form field:
+ * OpenAdmin\Admin\Form::forget(['map', 'editor']);
+ *
+ * Or extend custom form field:
+ * OpenAdmin\Admin\Form::extend('php', PHPEditor::class);
+ *
+ * Or require js and css assets:
+ * Admin::css('/packages/prettydocs/css/styles.css');
+ * Admin::js('/packages/prettydocs/js/main.js');
+ *
+ */
+
+OpenAdmin\Admin\Form::forget(['editor']);
diff --git a/workbench/app/Admin/routes.php b/workbench/app/Admin/routes.php
new file mode 100644
index 00000000..57b0d520
--- /dev/null
+++ b/workbench/app/Admin/routes.php
@@ -0,0 +1,19 @@
+ config('admin.route.prefix'),
+ 'namespace' => config('admin.route.namespace'),
+ 'middleware' => config('admin.route.middleware'),
+ 'as' => config('admin.route.prefix').'.',
+], static function (Router $router) {
+ $router->get('/', [HomeController::class, 'index'])->name('home');
+});
diff --git a/tests/controllers/FileController.php b/workbench/app/Http/Controllers/FileController.php
similarity index 90%
rename from tests/controllers/FileController.php
rename to workbench/app/Http/Controllers/FileController.php
index 62a0db19..bc940491 100644
--- a/tests/controllers/FileController.php
+++ b/workbench/app/Http/Controllers/FileController.php
@@ -1,11 +1,13 @@
belongsTo(User::class, 'user_id');
+ }
+}
diff --git a/workbench/app/Models/Tag.php b/workbench/app/Models/Tag.php
new file mode 100644
index 00000000..50d9f632
--- /dev/null
+++ b/workbench/app/Models/Tag.php
@@ -0,0 +1,31 @@
+belongsToMany(User::class, 'test_user_tags', 'tag_id', 'user_id');
+ }
+}
diff --git a/tests/models/Tree.php b/workbench/app/Models/Tree.php
similarity index 90%
rename from tests/models/Tree.php
rename to workbench/app/Models/Tree.php
index 4d444a72..3192beb5 100644
--- a/tests/models/Tree.php
+++ b/workbench/app/Models/Tree.php
@@ -1,6 +1,8 @@
'array'];
+
+ protected static function newFactory(): UserFactory
+ {
+ return UserFactory::new();
+ }
+
+ public function profile(): HasOne
+ {
+ return $this->hasOne(Profile::class, 'user_id');
+ }
+
+ public function tags(): BelongsToMany
+ {
+ return $this->belongsToMany(Tag::class, 'test_user_tags', 'user_id', 'tag_id');
+ }
+
+ public function getFullNameAttribute(): string
+ {
+ return "{$this->profile['first_name']} {$this->profile['last_name']}";
+ }
+
+ public function getPositionAttribute(): string
+ {
+ return "{$this->profile->latitude} {$this->profile->longitude}";
+ }
+}
diff --git a/workbench/app/Providers/WorkbenchServiceProvider.php b/workbench/app/Providers/WorkbenchServiceProvider.php
new file mode 100644
index 00000000..d09c191d
--- /dev/null
+++ b/workbench/app/Providers/WorkbenchServiceProvider.php
@@ -0,0 +1,26 @@
+withRouting(
+ web: __DIR__.'/../routes/web.php',
+ commands: __DIR__.'/../routes/console.php',
+ )
+ ->withMiddleware(function (Middleware $middleware) {
+ //
+ })
+ ->withExceptions(function (Exceptions $exceptions) {
+ //
+ })->create();
diff --git a/workbench/bootstrap/providers.php b/workbench/bootstrap/providers.php
new file mode 100644
index 00000000..f6866b43
--- /dev/null
+++ b/workbench/bootstrap/providers.php
@@ -0,0 +1,9 @@
+
+ */
+class ProfileFactory extends Factory
+{
+ protected $model = Profile::class;
+
+ public function definition(): array
+ {
+ return [
+ 'first_name' => $this->faker->firstName(),
+ 'last_name' => $this->faker->lastName(),
+ 'postcode' => $this->faker->postcode(),
+ 'address' => $this->faker->address(),
+ 'latitude' => $this->faker->latitude(),
+ 'longitude' => $this->faker->longitude(),
+ 'color' => $this->faker->hexColor(),
+ 'start_at' => $this->faker->dateTime(),
+ 'end_at' => $this->faker->dateTime(),
+ ];
+ }
+}
diff --git a/workbench/database/factories/TagFactory.php b/workbench/database/factories/TagFactory.php
new file mode 100644
index 00000000..5d81e489
--- /dev/null
+++ b/workbench/database/factories/TagFactory.php
@@ -0,0 +1,23 @@
+
+ */
+class TagFactory extends Factory
+{
+ protected $model = Tag::class;
+
+ public function definition(): array
+ {
+ return [
+ 'name' => $this->faker->word(),
+ ];
+ }
+}
diff --git a/workbench/database/factories/UserFactory.php b/workbench/database/factories/UserFactory.php
new file mode 100644
index 00000000..c46843cd
--- /dev/null
+++ b/workbench/database/factories/UserFactory.php
@@ -0,0 +1,33 @@
+
+ */
+class UserFactory extends Factory
+{
+ protected $model = User::class;
+
+ public function definition(): array
+ {
+ return [
+ 'username' => $this->faker->userName(),
+ 'email' => $this->faker->email(),
+ 'mobile' => $this->faker->phoneNumber(),
+ 'avatar' => $this->faker->imageUrl(),
+ 'password' => Hash::make('123456'),
+ 'data' => [
+ 'json' => [
+ 'field' => $this->faker->numberBetween(1, 50),
+ ],
+ ],
+ ];
+ }
+}
diff --git a/workbench/database/migrations/.gitkeep b/workbench/database/migrations/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/migrations/2016_11_22_093148_create_test_tables.php b/workbench/database/migrations/2016_11_22_093148_create_test_tables.php
similarity index 77%
rename from tests/migrations/2016_11_22_093148_create_test_tables.php
rename to workbench/database/migrations/2016_11_22_093148_create_test_tables.php
index 3632bd1d..275a8be4 100644
--- a/tests/migrations/2016_11_22_093148_create_test_tables.php
+++ b/workbench/database/migrations/2016_11_22_093148_create_test_tables.php
@@ -1,18 +1,15 @@
increments('id');
$table->string('image1');
$table->string('image2');
@@ -23,13 +20,13 @@ public function up()
$table->timestamps();
});
- Schema::create('test_multiple_images', function (Blueprint $table) {
+ Schema::create('test_multiple_images', static function (Blueprint $table) {
$table->increments('id');
$table->text('pictures');
$table->timestamps();
});
- Schema::create('test_files', function (Blueprint $table) {
+ Schema::create('test_files', static function (Blueprint $table) {
$table->increments('id');
$table->string('file1');
$table->string('file2');
@@ -40,7 +37,7 @@ public function up()
$table->timestamps();
});
- Schema::create('test_users', function (Blueprint $table) {
+ Schema::create('test_users', static function (Blueprint $table) {
$table->increments('id');
$table->string('username');
$table->string('email');
@@ -51,7 +48,7 @@ public function up()
$table->timestamps();
});
- Schema::create('test_user_profiles', function (Blueprint $table) {
+ Schema::create('test_user_profiles', static function (Blueprint $table) {
$table->increments('id');
$table->string('user_id');
$table->string('first_name')->nullable();
@@ -67,13 +64,13 @@ public function up()
$table->timestamps();
});
- Schema::create('test_tags', function (Blueprint $table) {
+ Schema::create('test_tags', static function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
- Schema::create('test_user_tags', function (Blueprint $table) {
+ Schema::create('test_user_tags', static function (Blueprint $table) {
$table->integer('user_id');
$table->integer('tag_id');
$table->index(['user_id', 'tag_id']);
@@ -81,12 +78,7 @@ public function up()
});
}
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
+ public function down(): void
{
Schema::dropIfExists('test_images');
Schema::dropIfExists('test_multiple_images');
@@ -96,4 +88,4 @@ public function down()
Schema::dropIfExists('test_tags');
Schema::dropIfExists('test_user_tags');
}
-}
+};
diff --git a/workbench/database/seeders/.gitkeep b/workbench/database/seeders/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/workbench/database/seeders/DatabaseSeeder.php b/workbench/database/seeders/DatabaseSeeder.php
new file mode 100644
index 00000000..e6c427a8
--- /dev/null
+++ b/workbench/database/seeders/DatabaseSeeder.php
@@ -0,0 +1,22 @@
+call(AdminTablesSeeder::class);
+ }
+
+ $this->call(UserTableSeeder::class);
+ }
+}
diff --git a/workbench/database/seeders/UserTableSeeder.php b/workbench/database/seeders/UserTableSeeder.php
new file mode 100644
index 00000000..7743a41a
--- /dev/null
+++ b/workbench/database/seeders/UserTableSeeder.php
@@ -0,0 +1,24 @@
+count(50)
+ ->create()
+ ->each(function (User $user) {
+ Profile::factory()->for($user, 'user')->create();
+ $user->tags()->saveMany(Tag::factory()->count(5)->make());
+ });
+ }
+}
diff --git a/workbench/resources/views/.gitkeep b/workbench/resources/views/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/workbench/routes/.gitkeep b/workbench/routes/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/workbench/routes/api.php b/workbench/routes/api.php
new file mode 100644
index 00000000..2a8b0e22
--- /dev/null
+++ b/workbench/routes/api.php
@@ -0,0 +1,18 @@
+get('/user', function (Request $request) {
+// return $request->user();
+// });
diff --git a/workbench/routes/console.php b/workbench/routes/console.php
new file mode 100644
index 00000000..bf4b0c51
--- /dev/null
+++ b/workbench/routes/console.php
@@ -0,0 +1,18 @@
+comment(Inspiring::quote());
+// })->purpose('Display an inspiring quote');
diff --git a/workbench/routes/web.php b/workbench/routes/web.php
new file mode 100644
index 00000000..f89fecd9
--- /dev/null
+++ b/workbench/routes/web.php
@@ -0,0 +1,35 @@
+ config('admin.route.prefix'),
+ 'middleware' => ['web', 'admin'],
+], static function (Router $router) {
+ $router->resource('images', ImageController::class);
+ $router->resource('multiple-images', MultipleImageController::class);
+ $router->resource('files', FileController::class);
+ $router->resource('users', UserController::class);
+});