Skip to content

Commit a5d7922

Browse files
committed
add workbench
1 parent c6616dd commit a5d7922

File tree

13 files changed

+208
-6
lines changed

13 files changed

+208
-6
lines changed

composer.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"web3p/web3.php": "^0.1.6"
2626
},
2727
"require-dev": {
28+
"larastan/larastan": "^3.0",
2829
"laravel/pint": "^1.14",
2930
"nunomaduro/collision": "^8.8",
30-
"larastan/larastan": "^3.0",
31-
"orchestra/testbench": "^10.0.0||^9.0.0",
31+
"orchestra/testbench": "^10.6",
3232
"pestphp/pest": "^4.0",
3333
"pestphp/pest-plugin-arch": "^4.0",
3434
"pestphp/pest-plugin-laravel": "^4.0",
@@ -44,16 +44,33 @@
4444
"autoload-dev": {
4545
"psr-4": {
4646
"Farbcode\\LaravelEvm\\Tests\\": "tests/",
47-
"Workbench\\App\\": "workbench/app/"
47+
"Workbench\\App\\": "workbench/app/",
48+
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
49+
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
4850
}
4951
},
5052
"scripts": {
51-
"post-autoload-dump": "@composer run prepare",
53+
"post-autoload-dump": [
54+
"@clear",
55+
"@prepare",
56+
"@composer run prepare"
57+
],
5258
"prepare": "@php vendor/bin/testbench package:discover --ansi",
5359
"analyse": "vendor/bin/phpstan analyse",
5460
"test": "vendor/bin/pest",
5561
"test-coverage": "vendor/bin/pest --coverage",
56-
"format": "vendor/bin/pint"
62+
"format": "vendor/bin/pint",
63+
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
64+
"build": "@php vendor/bin/testbench workbench:build --ansi",
65+
"serve": [
66+
"Composer\\Config::disableProcessTimeout",
67+
"@build",
68+
"@php vendor/bin/testbench serve --ansi"
69+
],
70+
"lint": [
71+
"@php vendor/bin/pint --ansi",
72+
"@php vendor/bin/phpstan analyse --verbose --ansi"
73+
]
5774
},
5875
"config": {
5976
"sort-packages": true,
@@ -74,4 +91,4 @@
7491
},
7592
"minimum-stability": "dev",
7693
"prefer-stable": true
77-
}
94+
}

workbench/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
.env.dusk

workbench/app/Models/.gitkeep

Whitespace-only changes.

workbench/app/Models/User.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Workbench\App\Models;
4+
5+
// use Illuminate\Contracts\Auth\MustVerifyEmail;
6+
use Illuminate\Database\Eloquent\Factories\HasFactory;
7+
use Illuminate\Foundation\Auth\User as Authenticatable;
8+
use Illuminate\Notifications\Notifiable;
9+
10+
class User extends Authenticatable
11+
{
12+
/** @use HasFactory<\Workbench\Workbench\Workbench\Database\Factories\UserFactory> */
13+
use HasFactory, Notifiable;
14+
15+
/**
16+
* The attributes that are mass assignable.
17+
*
18+
* @var list<string>
19+
*/
20+
protected $fillable = [
21+
'name',
22+
'email',
23+
'password',
24+
];
25+
26+
/**
27+
* The attributes that should be hidden for serialization.
28+
*
29+
* @var list<string>
30+
*/
31+
protected $hidden = [
32+
'password',
33+
'remember_token',
34+
];
35+
36+
/**
37+
* Get the attributes that should be cast.
38+
*
39+
* @return array<string, string>
40+
*/
41+
protected function casts(): array
42+
{
43+
return [
44+
'email_verified_at' => 'datetime',
45+
'password' => 'hashed',
46+
];
47+
}
48+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Workbench\App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class WorkbenchServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Register services.
11+
*/
12+
public function register(): void
13+
{
14+
//
15+
}
16+
17+
/**
18+
* Bootstrap services.
19+
*/
20+
public function boot(): void
21+
{
22+
//
23+
}
24+
}

workbench/bootstrap/app.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
use Illuminate\Foundation\Application;
4+
use Illuminate\Foundation\Configuration\Exceptions;
5+
use Illuminate\Foundation\Configuration\Middleware;
6+
7+
use function Orchestra\Testbench\default_skeleton_path;
8+
9+
return Application::configure(basePath: $APP_BASE_PATH ?? default_skeleton_path())
10+
->withRouting(
11+
web: __DIR__.'/../routes/web.php',
12+
commands: __DIR__.'/../routes/console.php',
13+
)
14+
->withMiddleware(function (Middleware $middleware) {
15+
//
16+
})
17+
->withExceptions(function (Exceptions $exceptions) {
18+
//
19+
})->create();

workbench/database/factories/.gitkeep

Whitespace-only changes.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Workbench\Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use Illuminate\Support\Facades\Hash;
7+
use Illuminate\Support\Str;
8+
use Workbench\App\Models\User;
9+
10+
/**
11+
* @template TModel of \Workbench\App\Models\User
12+
*
13+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel>
14+
*/
15+
class UserFactory extends Factory
16+
{
17+
/**
18+
* The current password being used by the factory.
19+
*/
20+
protected static ?string $password;
21+
22+
/**
23+
* The name of the factory's corresponding model.
24+
*
25+
* @var class-string<TModel>
26+
*/
27+
protected $model = User::class;
28+
29+
/**
30+
* Define the model's default state.
31+
*
32+
* @return array<string, mixed>
33+
*/
34+
public function definition(): array
35+
{
36+
return [
37+
'name' => fake()->name(),
38+
'email' => fake()->unique()->safeEmail(),
39+
'email_verified_at' => now(),
40+
'password' => static::$password ??= Hash::make('password'),
41+
'remember_token' => Str::random(10),
42+
];
43+
}
44+
45+
/**
46+
* Indicate that the model's email address should be unverified.
47+
*/
48+
public function unverified(): static
49+
{
50+
return $this->state(fn (array $attributes) => [
51+
'email_verified_at' => null,
52+
]);
53+
}
54+
}

workbench/database/migrations/.gitkeep

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Workbench\Database\Seeders;
4+
5+
use Illuminate\Database\Seeder;
6+
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
7+
use Workbench\Workbench\Workbench\Database\Factories\UserFactory;
8+
9+
class DatabaseSeeder extends Seeder
10+
{
11+
/**
12+
* Seed the application's database.
13+
*/
14+
public function run(): void
15+
{
16+
// UserFactory::new()->times(10)->create();
17+
18+
UserFactory::new()->create([
19+
'name' => 'Test User',
20+
'email' => 'test@example.com',
21+
]);
22+
}
23+
}

0 commit comments

Comments
 (0)