mirror of
https://gitlab.com/izyim/prototypes/lumen-microservices/microservice-api-gateway.git
synced 2026-08-19 04:24:15 +00:00
fixing missed step
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
@@ -12,18 +14,16 @@ class Kernel extends ConsoleKernel
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
protected $commands = [];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
class ExampleEvent extends Event
|
||||
{
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Traits\ApiResponse;
|
||||
@@ -13,6 +15,8 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
use function env;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
use ApiResponse;
|
||||
@@ -51,7 +55,6 @@ class Handler extends ExceptionHandler
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
|
||||
if ($exception instanceof HttpException) {
|
||||
$errorCode = $exception->getStatusCode();
|
||||
$errorMessage = Response::$statusTexts[$errorCode];
|
||||
@@ -99,6 +102,5 @@ class Handler extends ExceptionHandler
|
||||
return $this->errorResponse(
|
||||
"Unexpected error. Try later!",
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Traits\ApiResponse;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\OrderService;
|
||||
@@ -8,42 +10,74 @@ use Illuminate\Http\Request;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \App\Services\OrderService
|
||||
*/
|
||||
protected $orderService;
|
||||
|
||||
private $orderService;
|
||||
private $productService;
|
||||
/**
|
||||
* @var \App\Services\ProductService
|
||||
*/
|
||||
protected $productService;
|
||||
|
||||
/**
|
||||
* OrderController constructor.
|
||||
*
|
||||
* @param \App\Services\OrderService $orderService
|
||||
* @param \App\Services\ProductService $productService
|
||||
*/
|
||||
public function __construct(OrderService $orderService, ProductService $productService)
|
||||
{
|
||||
$this->orderService = $orderService;
|
||||
$this->productService = $productService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->successResponse($this->orderService->fetchOrders());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show($order)
|
||||
{
|
||||
return $this->successResponse($this->orderService->fetchOrder($order));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$result = $this->productService->fetchProduct($request->product_id);
|
||||
// dd($result);
|
||||
|
||||
return $this->successResponse($this->orderService->createOrder($request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $order
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(Request $request, $order)
|
||||
{
|
||||
return $this->successResponse($this->orderService->updateOrder($order, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function destroy($order)
|
||||
{
|
||||
return $this->successResponse($this->orderService->deleteOrder($order));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\ProductService;
|
||||
@@ -10,31 +12,60 @@ class ProductController extends Controller
|
||||
|
||||
private $productService;
|
||||
|
||||
/**
|
||||
* ProductController constructor.
|
||||
*
|
||||
* @param \App\Services\ProductService $productService
|
||||
*/
|
||||
public function __construct(ProductService $productService)
|
||||
{
|
||||
$this->productService = $productService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->successResponse($this->productService->fetchProducts());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $product
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function show($product)
|
||||
{
|
||||
return $this->successResponse($this->productService->fetchProduct($product));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
return $this->successResponse($this->productService->createProduct($request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $product
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(Request $request, $product)
|
||||
{
|
||||
return $this->successResponse($this->productService->updateProduct($product, $request->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $product
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function destroy($product)
|
||||
{
|
||||
return $this->successResponse($this->productService->deleteProduct($product));
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
|
||||
use function response;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class ExampleJob extends Job
|
||||
@@ -11,7 +13,6 @@ class ExampleJob extends Job
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,8 +20,7 @@ class ExampleJob extends Job
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle() : void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\ExampleEvent;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class ExampleListener
|
||||
{
|
||||
@@ -15,7 +15,6 @@ class ExampleListener
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,6 +25,5 @@ class ExampleListener
|
||||
*/
|
||||
public function handle(ExampleEvent $event)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@@ -13,6 +15,5 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\User;
|
||||
use Dusterio\LumenPassport\LumenPassport;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
@@ -16,11 +16,16 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Boot the authentication services for the application.
|
||||
* If you desire to handle the request via simple mechanism
|
||||
* $this->app['auth']->viaRequest('api', function ($request) {
|
||||
* if ($request->input('api_token')) {
|
||||
* return User::where('api_token', $request->input('api_token'))->first();
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -31,12 +36,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
// should return either a User instance or null. You're free to obtain
|
||||
// the User instance via an API token or any other method necessary.
|
||||
|
||||
// $this->app['auth']->viaRequest('api', function ($request) {
|
||||
// if ($request->input('api_token')) {
|
||||
// return User::where('api_token', $request->input('api_token'))->first();
|
||||
// }
|
||||
// });
|
||||
|
||||
LumenPassport::routes($this->app->router);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
@@ -1,15 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Traits\RequestService;
|
||||
|
||||
use function config;
|
||||
|
||||
class OrderService
|
||||
{
|
||||
use RequestService;
|
||||
|
||||
public $baseUri;
|
||||
public $secret;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUri;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $secret;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -17,27 +28,51 @@ class OrderService
|
||||
$this->secret = config('services.orders.secret');
|
||||
}
|
||||
|
||||
public function fetchOrders()
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function fetchOrders() : string
|
||||
{
|
||||
return $this->request('GET', '/api/order');
|
||||
}
|
||||
|
||||
public function fetchOrder($order)
|
||||
/**
|
||||
* @param $order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchOrder($order) : string
|
||||
{
|
||||
return $this->request('GET', "/api/order/{$order}");
|
||||
}
|
||||
|
||||
public function createOrder($data)
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createOrder($data) : string
|
||||
{
|
||||
return $this->request('POST', '/api/order', $data);
|
||||
}
|
||||
|
||||
public function updateOrder($order, $data)
|
||||
/**
|
||||
* @param $order
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function updateOrder($order, $data) : string
|
||||
{
|
||||
return $this->request('PATCH', "/api/order/{$order}", $data);
|
||||
}
|
||||
|
||||
public function deleteOrder($order)
|
||||
/**
|
||||
* @param $order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteOrder($order) : string
|
||||
{
|
||||
return $this->request('DELETE', "/api/order/{$order}");
|
||||
}
|
||||
|
||||
@@ -1,46 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Traits\RequestService;
|
||||
|
||||
use function config;
|
||||
|
||||
class ProductService
|
||||
{
|
||||
use RequestService;
|
||||
|
||||
public $baseUri;
|
||||
public $secret;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUri;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $secret;
|
||||
|
||||
/**
|
||||
* ProductService constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->baseUri = config('services.products.base_uri');
|
||||
$this->secret = config('services.products.secret');
|
||||
}
|
||||
|
||||
|
||||
public function fetchProducts()
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function fetchProducts() : string
|
||||
{
|
||||
return $this->request('GET', '/api/product');
|
||||
}
|
||||
|
||||
public function fetchProduct($product)
|
||||
/**
|
||||
* @param $product
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchProduct($product) : string
|
||||
{
|
||||
return $this->request('GET', "/api/product/{$product}");
|
||||
}
|
||||
|
||||
public function createProduct($data)
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createProduct($data) : string
|
||||
{
|
||||
return $this->request('POST', '/api/product', $data);
|
||||
}
|
||||
|
||||
public function updateProduct($product, $data)
|
||||
/**
|
||||
* @param $product
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function updateProduct($product, $data) : string
|
||||
{
|
||||
return $this->request('PATCH', "/api/product/{$product}", $data);
|
||||
}
|
||||
|
||||
public function deleteProduct($product)
|
||||
/**
|
||||
* @param $product
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteProduct($product) : string
|
||||
{
|
||||
return $this->request('DELETE', "/api/product/{$product}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
use function response;
|
||||
|
||||
trait ApiResponse
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param int $statusCode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function successResponse($data, $statusCode = Response::HTTP_OK)
|
||||
{
|
||||
return response($data, $statusCode)->header('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $errorMessage
|
||||
* @param $statusCode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function errorResponse($errorMessage, $statusCode)
|
||||
{
|
||||
return response()->json(['error' => $errorMessage, 'error_code' => $statusCode], $statusCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $errorMessage
|
||||
* @param $statusCode
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function errorMessage($errorMessage, $statusCode)
|
||||
{
|
||||
return response($errorMessage, $statusCode)->header('Content-Type', 'application/json');
|
||||
|
||||
@@ -1,27 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
trait RequestService
|
||||
{
|
||||
|
||||
public function request($method, $requestUrl, $formParams = [], $headers = [])
|
||||
/**
|
||||
* @param $method
|
||||
* @param $requestUrl
|
||||
* @param array $formParams
|
||||
* @param array $headers
|
||||
*
|
||||
* @return string
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function request($method, $requestUrl, $formParams = [], $headers = []) : string
|
||||
{
|
||||
$client = new Client([
|
||||
'base_uri' => $this->baseUri
|
||||
]);
|
||||
|
||||
if (isset($this->secret)) {
|
||||
$headers['Authorization'] = $this->secret;
|
||||
}
|
||||
|
||||
$response = $client->request($method, $requestUrl,
|
||||
[
|
||||
'form_params' => $formParams,
|
||||
'headers' => $headers
|
||||
]
|
||||
);
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
}
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
@@ -15,10 +17,10 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email',
|
||||
'name', 'email'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
+5
-1
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
(new Dotenv\Dotenv(dirname(__DIR__)))->load();
|
||||
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
|
||||
dirname(__DIR__)
|
||||
))->bootstrap();
|
||||
} catch (Dotenv\Exception\InvalidPathException $e) {
|
||||
//
|
||||
}
|
||||
|
||||
+5
-4
@@ -8,13 +8,14 @@
|
||||
"php": ">=7.1.3",
|
||||
"dusterio/lumen-passport": "^0.2.15",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"laravel/lumen-framework": "5.7.*",
|
||||
"vlucas/phpdotenv": "~2.2"
|
||||
"laravel/lumen-framework": "5.8.*",
|
||||
"lcobucci/jwt": "3.3.3",
|
||||
"vlucas/phpdotenv": "^3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
"phpunit/phpunit": "~7.0",
|
||||
"mockery/mockery": "~1.0"
|
||||
"mockery/mockery": "~1.0",
|
||||
"phpunit/phpunit": "~7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
return [
|
||||
'defaults' => [
|
||||
'guard' => 'api',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
return [
|
||||
'products' => [
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
@@ -10,4 +12,3 @@
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up() : void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name', 256);
|
||||
$table->string('email', 256);
|
||||
$table->string('password', 512);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down() : void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
@@ -11,6 +13,7 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call('UsersTableSeeder');
|
||||
\Illuminate\Support\Facades\Artisan::call('passport:install');
|
||||
$this->call(UserTableSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
\App\User::create([
|
||||
'name' => 'user1',
|
||||
'email' => 'user1@gmail.com',
|
||||
'password' => Hash::make('123456')
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
|
||||
Reference in New Issue
Block a user