├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── app ├── Console │ └── Kernel.php ├── Constants │ ├── AuthConstants.php │ ├── CategoryConstants.php │ ├── ProductConstants.php │ └── ValidationConstants.php ├── Events │ └── UserRegistered.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── API │ │ │ ├── Auth │ │ │ │ ├── ForgotPasswordController.php │ │ │ │ ├── LoginController.php │ │ │ │ ├── RegisterController.php │ │ │ │ └── ResetPasswordController.php │ │ │ ├── CategoryController.php │ │ │ └── ProductController.php │ │ └── Controller.php │ ├── Kernel.php │ ├── Middleware │ │ ├── ApiAuthenticate.php │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ ├── ValidateSignature.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ ├── AuthRequest.php │ │ ├── CategoryRequest.php │ │ ├── ProductRequest.php │ │ └── RegisterRequest.php │ ├── Resources │ │ ├── CategoryResource.php │ │ └── ProductResource.php │ └── Traits │ │ ├── Access.php │ │ └── HttpResponses.php ├── Jobs │ └── UserRegisteredEmailJob.php ├── Listeners │ └── UserRegisteredEmailNotification.php ├── Models │ ├── Category.php │ ├── Product.php │ └── User.php ├── Observers │ ├── CategoryObserver.php │ └── ProductObserver.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── HorizonServiceProvider.php │ ├── RouteServiceProvider.php │ └── TelescopeServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filesystems.php ├── hashing.php ├── horizon.php ├── logging.php ├── mail.php ├── queue.php ├── request-docs.php ├── sanctum.php ├── services.php ├── session.php ├── telescope.php └── view.php ├── database ├── .gitignore ├── factories │ ├── CategoryFactory.php │ ├── ProductFactory.php │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ ├── 2018_08_08_100000_create_telescope_entries_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2023_03_06_095645_create_products_table.php │ ├── 2023_03_06_095651_create_categories_table.php │ └── 2023_03_06_095659_create_category_product_table.php └── seeders │ └── DatabaseSeeder.php ├── docker-compose.yml ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── favicon.ico ├── index.php ├── robots.txt └── vendor │ ├── horizon │ ├── app-dark.css │ ├── app.css │ ├── app.js │ ├── img │ │ ├── favicon.png │ │ ├── horizon.svg │ │ └── sprite.svg │ └── mix-manifest.json │ └── telescope │ ├── app-dark.css │ ├── app.css │ ├── app.js │ ├── favicon.ico │ └── mix-manifest.json ├── resources ├── css │ └── app.css ├── js │ ├── app.js │ └── bootstrap.js └── views │ └── welcome.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ └── Api │ │ ├── CategoryControllerTest.php │ │ ├── LoginControllerTest.php │ │ ├── ProductControllerTest.php │ │ └── RegisterControllerTest.php └── TestCase.php └── vite.config.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=simple_laravel_api 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 55 | VITE_PUSHER_HOST="${PUSHER_HOST}" 56 | VITE_PUSHER_PORT="${PUSHER_PORT}" 57 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 58 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 59 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | Homestead.json 10 | Homestead.yaml 11 | npm-debug.log 12 | yarn-error.log 13 | /.idea 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Simple Laravel 10 REST API 2 | 3 | Simple Laravel 10 REST API with Sanctum Registration/Authentication, Products + Categories. 4 | 5 | Install: 6 | - Run Docker 7 | - ./vendor/bin/sail up 8 | 9 | From Docker container: 10 | - composer install 11 | - php artisan key:generate 12 | - php artisan migrate 13 | - php artisan queue:work (For queues) 14 | 15 | PS. For queues don`t forget to select driver (Redis, ...). 16 | 17 | API Structure: 18 | CRUD[GET, POST, PUT/PATCH, DELETE] for Categories and Products 19 | [POST] Login / Register 20 | 21 | API Dock: http://localhost/request-docs/ 22 | Telescope: http://localhost/telescope/ 23 | Horizon: http://localhost/horizon 24 | 25 | Best regards. -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Constants/AuthConstants.php: -------------------------------------------------------------------------------- 1 | user = $user; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | , \Psr\Log\LogLevel::*> 14 | */ 15 | protected $levels = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * A list of the exception types that are not reported. 21 | * 22 | * @var array> 23 | */ 24 | protected $dontReport = [ 25 | // 26 | ]; 27 | 28 | /** 29 | * A list of the inputs that are never flashed to the session on validation exceptions. 30 | * 31 | * @var array 32 | */ 33 | protected $dontFlash = [ 34 | 'current_password', 35 | 'password', 36 | 'password_confirmation', 37 | ]; 38 | 39 | /** 40 | * Register the exception handling callbacks for the application. 41 | */ 42 | public function register(): void 43 | { 44 | $this->reportable(function (Throwable $e) { 45 | // 46 | }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Http/Controllers/API/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | attempt($request->all())) { 22 | $user = auth()->user(); 23 | 24 | $user->tokens()->delete(); 25 | 26 | $success = $user->createToken('MyApp')->plainTextToken; 27 | 28 | return $this->success(['token' => $success], AuthConstants::LOGIN); 29 | } 30 | 31 | return $this->error([], AuthConstants::VALIDATION); 32 | } 33 | 34 | /** 35 | * @return JsonResponse 36 | */ 37 | public function logout(): JsonResponse 38 | { 39 | $user = auth()->user(); 40 | 41 | $user->tokens()->delete(); 42 | 43 | return $this->success([], AuthConstants::LOGOUT); 44 | } 45 | 46 | /** 47 | * @return JsonResponse 48 | */ 49 | public function details(): JsonResponse 50 | { 51 | $user = auth()->user(); 52 | 53 | return $this->success($user, ''); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Http/Controllers/API/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | all(); 24 | $input['password'] = bcrypt($input['password']); 25 | $user = User::create($input); 26 | $success['token'] = $user->createToken('MyApp')->plainTextToken; 27 | $success['name'] = $user->name; 28 | 29 | event(new UserRegistered($user)); 30 | 31 | return $this->success($success, AuthConstants::REGISTER); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Controllers/API/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | success( 26 | CategoryResource::collection(Category::ForUser()->get()) 27 | ); 28 | } 29 | 30 | /** 31 | * @param CategoryRequest $request 32 | * @return JsonResponse 33 | */ 34 | public function store(CategoryRequest $request): JsonResponse 35 | { 36 | return $this->success( 37 | new CategoryResource(auth()->user()->categories()->create($request->all())), 38 | CategoryConstants::STORE 39 | ); 40 | } 41 | 42 | /** 43 | * @param Category $category 44 | * @return JsonResponse 45 | */ 46 | public function show(Category $category): JsonResponse 47 | { 48 | if (!$this->canAccess($category)) { 49 | return $this->error([], AuthConstants::PERMISSION); 50 | } 51 | 52 | return $this->success(new CategoryResource($category)); 53 | } 54 | 55 | /** 56 | * @param CategoryRequest $request 57 | * @param Category $category 58 | * @return JsonResponse 59 | */ 60 | public function update(CategoryRequest $request, Category $category): JsonResponse 61 | { 62 | if (!$this->canAccess($category)) { 63 | return $this->error([], AuthConstants::PERMISSION); 64 | } 65 | 66 | $category->update($request->all()); 67 | 68 | return $this->success( 69 | new CategoryResource($category), 70 | CategoryConstants::UPDATE 71 | ); 72 | } 73 | 74 | /** 75 | * @param Category $category 76 | * @return JsonResponse 77 | */ 78 | public function destroy(Category $category): JsonResponse 79 | { 80 | if (!$this->canAccess($category)) { 81 | return $this->error([], AuthConstants::PERMISSION); 82 | } 83 | 84 | $category->delete(); 85 | 86 | return $this->success([], CategoryConstants::DESTROY); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/Http/Controllers/API/ProductController.php: -------------------------------------------------------------------------------- 1 | success(ProductResource::collection(Product::ForUser()->get())); 27 | } 28 | 29 | /** 30 | * @param ProductRequest $request 31 | * @return JsonResponse 32 | */ 33 | public function store(ProductRequest $request): JsonResponse 34 | { 35 | $product = auth()->user()->products()->create($request->all()); 36 | 37 | if (isset($request->categories)) { 38 | $categories = Category::ForUserByIds($request->categories); 39 | 40 | if (!$categories->isEmpty()) { 41 | $product->categories()->attach($categories); 42 | } 43 | } 44 | 45 | return $this->success(new ProductResource($product), ProductConstants::STORE); 46 | } 47 | 48 | /** 49 | * @param Product $product 50 | * @return JsonResponse 51 | */ 52 | public function show(Product $product): JsonResponse 53 | { 54 | if (!$this->canAccess($product)) { 55 | return $this->error([], AuthConstants::PERMISSION); 56 | } 57 | 58 | return $this->success(new ProductResource($product)); 59 | } 60 | 61 | /** 62 | * @param ProductRequest $request 63 | * @param Product $product 64 | * @return JsonResponse 65 | */ 66 | public function update(ProductRequest $request, Product $product): JsonResponse 67 | { 68 | if (!$this->canAccess($product)) { 69 | return $this->error(AuthConstants::PERMISSION); 70 | } 71 | 72 | if (isset($request->categories)) { 73 | $categories = Category::ForUserByIds($request->categories); 74 | 75 | $product->categories()->detach(); 76 | if (!$categories->isEmpty()) { 77 | $product->categories()->attach($categories); 78 | } 79 | } 80 | 81 | $product->update($request->all()); 82 | 83 | return $this->success(new ProductResource($product), ProductConstants::UPDATE); 84 | } 85 | 86 | /** 87 | * @param Product $product 88 | * @return JsonResponse 89 | */ 90 | public function destroy(Product $product): JsonResponse 91 | { 92 | if (!$this->canAccess($product)) { 93 | return $this->error(AuthConstants::PERMISSION); 94 | } 95 | 96 | $product->delete(); 97 | 98 | return $this->success([], ProductConstants::DESTROY); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Illuminate\Http\Middleware\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 37 | \App\Http\Middleware\VerifyCsrfToken::class, 38 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 39 | ], 40 | 41 | 'api' => [ 42 | \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 43 | \Illuminate\Routing\Middleware\ThrottleRequests::class . ':api', 44 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 45 | \Rakutentech\LaravelRequestDocs\LaravelRequestDocsMiddleware::class, 46 | ], 47 | ]; 48 | 49 | /** 50 | * The application's middleware aliases. 51 | * 52 | * Aliases may be used to conveniently assign middleware to routes and groups. 53 | * 54 | * @var array 55 | */ 56 | protected $middlewareAliases = [ 57 | 'auth' => \App\Http\Middleware\Authenticate::class, 58 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 59 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 60 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 61 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 62 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 63 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 64 | 'signed' => \App\Http\Middleware\ValidateSignature::class, 65 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 66 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 67 | 'api.auth' => \App\Http\Middleware\ApiAuthenticate::class, 68 | ]; 69 | } 70 | -------------------------------------------------------------------------------- /app/Http/Middleware/ApiAuthenticate.php: -------------------------------------------------------------------------------- 1 | user()) { 24 | auth()->login($user); 25 | 26 | return $next($request); 27 | } 28 | 29 | return $this->error([], AuthConstants::UNAUTHORIZED); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | guard($guard)->check()) { 26 | return redirect(RouteServiceProvider::HOME); 27 | } 28 | } 29 | 30 | return $next($request); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | '/api/*', 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Requests/AuthRequest.php: -------------------------------------------------------------------------------- 1 | 'required|email', 16 | 'password' => 'required', 17 | ]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Requests/CategoryRequest.php: -------------------------------------------------------------------------------- 1 | 'required|min:4', 16 | ]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Requests/ProductRequest.php: -------------------------------------------------------------------------------- 1 | 'required|min:4', 16 | 'price' => 'required|numeric', 17 | ]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Requests/RegisterRequest.php: -------------------------------------------------------------------------------- 1 | 'required|min:3', 16 | 'email' => 'required|email|unique:users,email', 17 | 'password' => 'required|min:6', 18 | 'confirm_password' => 'required|same:password' 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Resources/CategoryResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 18 | 'name' => $this->name, 19 | 'created_at' => $this->created_at, 20 | 'products' => ProductResource::collection($this->products), 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Resources/ProductResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 18 | 'name' => $this->name, 19 | 'price' => $this->price, 20 | 'created_at' => $this->created_at, 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Traits/Access.php: -------------------------------------------------------------------------------- 1 | user_id !== auth()->id()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Traits/HttpResponses.php: -------------------------------------------------------------------------------- 1 | json([ 19 | 'status' => '', 20 | 'message' => $message, 21 | 'data' => $data, 22 | ], $code); 23 | } 24 | 25 | /** 26 | * @param $data 27 | * @param string|null $message 28 | * @param int $code 29 | * @return JsonResponse 30 | */ 31 | protected function error( 32 | $data, 33 | string $message = null, 34 | int $code = ResponseAlias::HTTP_BAD_REQUEST 35 | ): JsonResponse { 36 | return response()->json([ 37 | 'status' => '', 38 | 'message' => $message, 39 | 'data' => $data, 40 | ], $code); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Jobs/UserRegisteredEmailJob.php: -------------------------------------------------------------------------------- 1 | user = $user; 30 | } 31 | 32 | /** 33 | * Execute the job. 34 | */ 35 | public function handle(): void 36 | { 37 | // TODO: Send email 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Listeners/UserRegisteredEmailNotification.php: -------------------------------------------------------------------------------- 1 | user)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Models/Category.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Product::class); 29 | } 30 | 31 | /** 32 | * @return BelongsTo 33 | */ 34 | public function user(): BelongsTo 35 | { 36 | return $this->belongsTo(User::class); 37 | } 38 | 39 | /** 40 | * @param Builder $query 41 | * @return Builder 42 | */ 43 | public function scopeForUser(Builder $query): Builder 44 | { 45 | return $query->where('user_id', auth()->id()); 46 | } 47 | 48 | /** 49 | * @param Builder $query 50 | * @param array $ids 51 | * @return Collection 52 | */ 53 | public function scopeForUserByIds(Builder $query, array $ids): Collection 54 | { 55 | return $query->find($ids)->where('user_id', auth()->id()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Models/Product.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Category::class); 28 | } 29 | 30 | /** 31 | * @param Builder $query 32 | * @return Builder 33 | */ 34 | public function scopeForUser(Builder $query): Builder 35 | { 36 | return $query->where('user_id', auth()->id()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | protected $fillable = [ 24 | 'name', 25 | 'email', 26 | 'password', 27 | ]; 28 | 29 | /** 30 | * The attributes that should be hidden for serialization. 31 | * 32 | * @var array 33 | */ 34 | protected $hidden = [ 35 | 'password', 36 | 'remember_token', 37 | ]; 38 | 39 | /** 40 | * The attributes that should be cast. 41 | * 42 | * @var array 43 | */ 44 | protected $casts = [ 45 | 'email_verified_at' => 'datetime', 46 | ]; 47 | 48 | /** 49 | * @return HasMany 50 | */ 51 | public function categories(): HasMany 52 | { 53 | return $this->hasMany(Category::class); 54 | } 55 | 56 | /** 57 | * @return HasMany 58 | */ 59 | public function products(): HasMany 60 | { 61 | return $this->hasMany(Product::class); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/Observers/CategoryObserver.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 'App\Models\Model' => 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 22 | */ 23 | protected $listen = [ 24 | Registered::class => [ 25 | SendEmailVerificationNotification::class, 26 | ], 27 | UserRegistered::class => [ 28 | UserRegisteredEmailNotification::class, 29 | ], 30 | ]; 31 | 32 | /** 33 | * Register any events for your application. 34 | */ 35 | public function boot(): void 36 | { 37 | Category::observe(new CategoryObserver()); 38 | Product::observe(new ProductObserver()); 39 | } 40 | 41 | /** 42 | * Determine if events and listeners should be automatically discovered. 43 | */ 44 | public function shouldDiscoverEvents(): bool 45 | { 46 | return false; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Providers/HorizonServiceProvider.php: -------------------------------------------------------------------------------- 1 | email, [ 34 | // 35 | ]); 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 28 | 29 | $this->routes(function () { 30 | Route::middleware('api') 31 | ->prefix('api') 32 | ->group(base_path('routes/api.php')); 33 | 34 | Route::middleware('web') 35 | ->group(base_path('routes/web.php')); 36 | }); 37 | } 38 | 39 | /** 40 | * Configure the rate limiters for the application. 41 | */ 42 | protected function configureRateLimiting(): void 43 | { 44 | RateLimiter::for('api', function (Request $request) { 45 | return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); 46 | }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Providers/TelescopeServiceProvider.php: -------------------------------------------------------------------------------- 1 | hideSensitiveRequestDetails(); 20 | 21 | Telescope::filter(function (IncomingEntry $entry) { 22 | if ($this->app->environment('local')) { 23 | return true; 24 | } 25 | 26 | return $entry->isReportableException() || 27 | $entry->isFailedRequest() || 28 | $entry->isFailedJob() || 29 | $entry->isScheduledTask() || 30 | $entry->hasMonitoredTag(); 31 | }); 32 | } 33 | 34 | /** 35 | * Prevent sensitive request details from being logged by Telescope. 36 | */ 37 | protected function hideSensitiveRequestDetails(): void 38 | { 39 | if ($this->app->environment('local')) { 40 | return; 41 | } 42 | 43 | Telescope::hideRequestParameters(['_token']); 44 | 45 | Telescope::hideRequestHeaders([ 46 | 'cookie', 47 | 'x-csrf-token', 48 | 'x-xsrf-token', 49 | ]); 50 | } 51 | 52 | /** 53 | * Register the Telescope gate. 54 | * 55 | * This gate determines who can access Telescope in non-local environments. 56 | */ 57 | protected function gate(): void 58 | { 59 | Gate::define('viewTelescope', function ($user) { 60 | return in_array($user->email, [ 61 | // 62 | ]); 63 | }); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": ["framework", "laravel"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^8.1", 9 | "guzzlehttp/guzzle": "^7.2", 10 | "laravel/framework": "^10.0", 11 | "laravel/horizon": "^5.15", 12 | "laravel/sanctum": "^3.2", 13 | "laravel/telescope": "^4.14", 14 | "laravel/tinker": "^2.8", 15 | "rakutentech/laravel-request-docs": "^2.14" 16 | }, 17 | "require-dev": { 18 | "fakerphp/faker": "^1.9.1", 19 | "laravel/pint": "^1.0", 20 | "laravel/sail": "^1.18", 21 | "mockery/mockery": "^1.4.4", 22 | "nunomaduro/collision": "^7.0", 23 | "phpunit/phpunit": "^10.0", 24 | "spatie/laravel-ignition": "^2.0" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "App\\": "app/", 29 | "Database\\Factories\\": "database/factories/", 30 | "Database\\Seeders\\": "database/seeders/" 31 | } 32 | }, 33 | "autoload-dev": { 34 | "psr-4": { 35 | "Tests\\": "tests/" 36 | } 37 | }, 38 | "scripts": { 39 | "post-autoload-dump": [ 40 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 41 | "@php artisan package:discover --ansi" 42 | ], 43 | "post-update-cmd": [ 44 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 45 | ], 46 | "post-root-package-install": [ 47 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 48 | ], 49 | "post-create-project-cmd": [ 50 | "@php artisan key:generate --ansi" 51 | ] 52 | }, 53 | "extra": { 54 | "laravel": { 55 | "dont-discover": [] 56 | } 57 | }, 58 | "config": { 59 | "optimize-autoloader": true, 60 | "preferred-install": "dist", 61 | "sort-packages": true, 62 | "allow-plugins": { 63 | "pestphp/pest-plugin": true, 64 | "php-http/discovery": true 65 | } 66 | }, 67 | "minimum-stability": "stable", 68 | "prefer-stable": true 69 | } 70 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Application Environment 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This value determines the "environment" your application is currently 26 | | running in. This may determine how you prefer to configure various 27 | | services the application utilizes. Set this in your ".env" file. 28 | | 29 | */ 30 | 31 | 'env' => env('APP_ENV', 'production'), 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Application Debug Mode 36 | |-------------------------------------------------------------------------- 37 | | 38 | | When your application is in debug mode, detailed error messages with 39 | | stack traces will be shown on every error that occurs within your 40 | | application. If disabled, a simple generic error page is shown. 41 | | 42 | */ 43 | 44 | 'debug' => (bool) env('APP_DEBUG', false), 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Application URL 49 | |-------------------------------------------------------------------------- 50 | | 51 | | This URL is used by the console to properly generate URLs when using 52 | | the Artisan command line tool. You should set this to the root of 53 | | your application so that it is used when running Artisan tasks. 54 | | 55 | */ 56 | 57 | 'url' => env('APP_URL', 'http://localhost'), 58 | 59 | 'asset_url' => env('ASSET_URL'), 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Application Timezone 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may specify the default timezone for your application, which 67 | | will be used by the PHP date and date-time functions. We have gone 68 | | ahead and set this to a sensible default for you out of the box. 69 | | 70 | */ 71 | 72 | 'timezone' => 'UTC', 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Application Locale Configuration 77 | |-------------------------------------------------------------------------- 78 | | 79 | | The application locale determines the default locale that will be used 80 | | by the translation service provider. You are free to set this value 81 | | to any of the locales which will be supported by the application. 82 | | 83 | */ 84 | 85 | 'locale' => 'en', 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Application Fallback Locale 90 | |-------------------------------------------------------------------------- 91 | | 92 | | The fallback locale determines the locale to use when the current one 93 | | is not available. You may change the value to correspond to any of 94 | | the language folders that are provided through your application. 95 | | 96 | */ 97 | 98 | 'fallback_locale' => 'en', 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Faker Locale 103 | |-------------------------------------------------------------------------- 104 | | 105 | | This locale will be used by the Faker PHP library when generating fake 106 | | data for your database seeds. For example, this will be used to get 107 | | localized telephone numbers, street address information and more. 108 | | 109 | */ 110 | 111 | 'faker_locale' => 'en_US', 112 | 113 | /* 114 | |-------------------------------------------------------------------------- 115 | | Encryption Key 116 | |-------------------------------------------------------------------------- 117 | | 118 | | This key is used by the Illuminate encrypter service and should be set 119 | | to a random, 32 character string, otherwise these encrypted strings 120 | | will not be safe. Please do this before deploying an application! 121 | | 122 | */ 123 | 124 | 'key' => env('APP_KEY'), 125 | 126 | 'cipher' => 'AES-256-CBC', 127 | 128 | /* 129 | |-------------------------------------------------------------------------- 130 | | Maintenance Mode Driver 131 | |-------------------------------------------------------------------------- 132 | | 133 | | These configuration options determine the driver used to determine and 134 | | manage Laravel's "maintenance mode" status. The "cache" driver will 135 | | allow maintenance mode to be controlled across multiple machines. 136 | | 137 | | Supported drivers: "file", "cache" 138 | | 139 | */ 140 | 141 | 'maintenance' => [ 142 | 'driver' => 'file', 143 | // 'store' => 'redis', 144 | ], 145 | 146 | /* 147 | |-------------------------------------------------------------------------- 148 | | Autoloaded Service Providers 149 | |-------------------------------------------------------------------------- 150 | | 151 | | The service providers listed here will be automatically loaded on the 152 | | request to your application. Feel free to add your own services to 153 | | this array to grant expanded functionality to your applications. 154 | | 155 | */ 156 | 157 | 'providers' => [ 158 | 159 | /* 160 | * Laravel Framework Service Providers... 161 | */ 162 | Illuminate\Auth\AuthServiceProvider::class, 163 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 164 | Illuminate\Bus\BusServiceProvider::class, 165 | Illuminate\Cache\CacheServiceProvider::class, 166 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 167 | Illuminate\Cookie\CookieServiceProvider::class, 168 | Illuminate\Database\DatabaseServiceProvider::class, 169 | Illuminate\Encryption\EncryptionServiceProvider::class, 170 | Illuminate\Filesystem\FilesystemServiceProvider::class, 171 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 172 | Illuminate\Hashing\HashServiceProvider::class, 173 | Illuminate\Mail\MailServiceProvider::class, 174 | Illuminate\Notifications\NotificationServiceProvider::class, 175 | Illuminate\Pagination\PaginationServiceProvider::class, 176 | Illuminate\Pipeline\PipelineServiceProvider::class, 177 | Illuminate\Queue\QueueServiceProvider::class, 178 | Illuminate\Redis\RedisServiceProvider::class, 179 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 180 | Illuminate\Session\SessionServiceProvider::class, 181 | Illuminate\Translation\TranslationServiceProvider::class, 182 | Illuminate\Validation\ValidationServiceProvider::class, 183 | Illuminate\View\ViewServiceProvider::class, 184 | 185 | /* 186 | * Package Service Providers... 187 | */ 188 | 189 | /* 190 | * Application Service Providers... 191 | */ 192 | App\Providers\AppServiceProvider::class, 193 | App\Providers\AuthServiceProvider::class, 194 | // App\Providers\BroadcastServiceProvider::class, 195 | App\Providers\EventServiceProvider::class, 196 | App\Providers\HorizonServiceProvider::class, 197 | App\Providers\RouteServiceProvider::class, 198 | App\Providers\TelescopeServiceProvider::class, 199 | 200 | ], 201 | 202 | /* 203 | |-------------------------------------------------------------------------- 204 | | Class Aliases 205 | |-------------------------------------------------------------------------- 206 | | 207 | | This array of class aliases will be registered when this application 208 | | is started. However, feel free to register as many as you wish as 209 | | the aliases are "lazy" loaded so they don't hinder performance. 210 | | 211 | */ 212 | 213 | 'aliases' => Facade::defaultAliases()->merge([ 214 | // 'ExampleClass' => App\Example\ExampleClass::class, 215 | ])->toArray(), 216 | 217 | ]; 218 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication drivers have a user provider. This defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | mechanisms used by this application to persist your user's data. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | sources which represent each model / table. These sources may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => App\Models\User::class, 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | You may specify multiple password reset configurations if you have more 80 | | than one user table or model in the application and you want to have 81 | | separate password reset settings based on the specific user types. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => 'password_reset_tokens', 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | times out and the user is prompted to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => 10800, 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 40 | 'port' => env('PUSHER_PORT', 443), 41 | 'scheme' => env('PUSHER_SCHEME', 'https'), 42 | 'encrypted' => true, 43 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 44 | ], 45 | 'client_options' => [ 46 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 47 | ], 48 | ], 49 | 50 | 'ably' => [ 51 | 'driver' => 'ably', 52 | 'key' => env('ABLY_KEY'), 53 | ], 54 | 55 | 'redis' => [ 56 | 'driver' => 'redis', 57 | 'connection' => 'default', 58 | ], 59 | 60 | 'log' => [ 61 | 'driver' => 'log', 62 | ], 63 | 64 | 'null' => [ 65 | 'driver' => 'null', 66 | ], 67 | 68 | ], 69 | 70 | ]; 71 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", 30 | | "memcached", "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | 'lock_connection' => null, 50 | ], 51 | 52 | 'file' => [ 53 | 'driver' => 'file', 54 | 'path' => storage_path('framework/cache/data'), 55 | ], 56 | 57 | 'memcached' => [ 58 | 'driver' => 'memcached', 59 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 60 | 'sasl' => [ 61 | env('MEMCACHED_USERNAME'), 62 | env('MEMCACHED_PASSWORD'), 63 | ], 64 | 'options' => [ 65 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 66 | ], 67 | 'servers' => [ 68 | [ 69 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 70 | 'port' => env('MEMCACHED_PORT', 11211), 71 | 'weight' => 100, 72 | ], 73 | ], 74 | ], 75 | 76 | 'redis' => [ 77 | 'driver' => 'redis', 78 | 'connection' => 'cache', 79 | 'lock_connection' => 'default', 80 | ], 81 | 82 | 'dynamodb' => [ 83 | 'driver' => 'dynamodb', 84 | 'key' => env('AWS_ACCESS_KEY_ID'), 85 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 86 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 87 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 88 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 89 | ], 90 | 91 | 'octane' => [ 92 | 'driver' => 'octane', 93 | ], 94 | 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Cache Key Prefix 100 | |-------------------------------------------------------------------------- 101 | | 102 | | When utilizing the APC, database, memcached, Redis, or DynamoDB cache 103 | | stores there might be other applications using the same cache. For 104 | | that reason, you may prefix every cache key to avoid collisions. 105 | | 106 | */ 107 | 108 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'search_path' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 93 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 94 | ], 95 | 96 | ], 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Migration Repository Table 101 | |-------------------------------------------------------------------------- 102 | | 103 | | This table keeps track of all the migrations that have already run for 104 | | your application. Using this information, we can determine which of 105 | | the migrations on disk haven't actually been run in the database. 106 | | 107 | */ 108 | 109 | 'migrations' => 'migrations', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Redis Databases 114 | |-------------------------------------------------------------------------- 115 | | 116 | | Redis is an open source, fast, and advanced key-value store that also 117 | | provides a richer body of commands than a typical key-value system 118 | | such as APC or Memcached. Laravel makes it easy to dig right in. 119 | | 120 | */ 121 | 122 | 'redis' => [ 123 | 124 | 'client' => env('REDIS_CLIENT', 'phpredis'), 125 | 126 | 'options' => [ 127 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 128 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 129 | ], 130 | 131 | 'default' => [ 132 | 'url' => env('REDIS_URL'), 133 | 'host' => env('REDIS_HOST', '127.0.0.1'), 134 | 'username' => env('REDIS_USERNAME'), 135 | 'password' => env('REDIS_PASSWORD'), 136 | 'port' => env('REDIS_PORT', '6379'), 137 | 'database' => env('REDIS_DB', '0'), 138 | ], 139 | 140 | 'cache' => [ 141 | 'url' => env('REDIS_URL'), 142 | 'host' => env('REDIS_HOST', '127.0.0.1'), 143 | 'username' => env('REDIS_USERNAME'), 144 | 'password' => env('REDIS_PASSWORD'), 145 | 'port' => env('REDIS_PORT', '6379'), 146 | 'database' => env('REDIS_CACHE_DB', '1'), 147 | ], 148 | 149 | ], 150 | 151 | ]; 152 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been set up for each driver as an example of the required values. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 65536, 48 | 'threads' => 1, 49 | 'time' => 4, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/horizon.php: -------------------------------------------------------------------------------- 1 | env('HORIZON_DOMAIN'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Horizon Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This is the URI path where Horizon will be accessible from. Feel free 26 | | to change this path to anything you like. Note that the URI will not 27 | | affect the paths of its internal API that aren't exposed to users. 28 | | 29 | */ 30 | 31 | 'path' => env('HORIZON_PATH', 'horizon'), 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Horizon Redis Connection 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This is the name of the Redis connection where Horizon will store the 39 | | meta information required for it to function. It includes the list 40 | | of supervisors, failed jobs, job metrics, and other information. 41 | | 42 | */ 43 | 44 | 'use' => 'default', 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Horizon Redis Prefix 49 | |-------------------------------------------------------------------------- 50 | | 51 | | This prefix will be used when storing all Horizon data in Redis. You 52 | | may modify the prefix when you are running multiple installations 53 | | of Horizon on the same server so that they don't have problems. 54 | | 55 | */ 56 | 57 | 'prefix' => env( 58 | 'HORIZON_PREFIX', 59 | Str::slug(env('APP_NAME', 'laravel'), '_').'_horizon:' 60 | ), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Horizon Route Middleware 65 | |-------------------------------------------------------------------------- 66 | | 67 | | These middleware will get attached onto each Horizon route, giving you 68 | | the chance to add your own middleware to this list or change any of 69 | | the existing middleware. Or, you can simply stick with this list. 70 | | 71 | */ 72 | 73 | 'middleware' => ['web'], 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Queue Wait Time Thresholds 78 | |-------------------------------------------------------------------------- 79 | | 80 | | This option allows you to configure when the LongWaitDetected event 81 | | will be fired. Every connection / queue combination may have its 82 | | own, unique threshold (in seconds) before this event is fired. 83 | | 84 | */ 85 | 86 | 'waits' => [ 87 | 'redis:default' => 60, 88 | ], 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Job Trimming Times 93 | |-------------------------------------------------------------------------- 94 | | 95 | | Here you can configure for how long (in minutes) you desire Horizon to 96 | | persist the recent and failed jobs. Typically, recent jobs are kept 97 | | for one hour while all failed jobs are stored for an entire week. 98 | | 99 | */ 100 | 101 | 'trim' => [ 102 | 'recent' => 60, 103 | 'pending' => 60, 104 | 'completed' => 60, 105 | 'recent_failed' => 10080, 106 | 'failed' => 10080, 107 | 'monitored' => 10080, 108 | ], 109 | 110 | /* 111 | |-------------------------------------------------------------------------- 112 | | Silenced Jobs 113 | |-------------------------------------------------------------------------- 114 | | 115 | | Silencing a job will instruct Horizon to not place the job in the list 116 | | of completed jobs within the Horizon dashboard. This setting may be 117 | | used to fully remove any noisy jobs from the completed jobs list. 118 | | 119 | */ 120 | 121 | 'silenced' => [ 122 | // App\Jobs\ExampleJob::class, 123 | ], 124 | 125 | /* 126 | |-------------------------------------------------------------------------- 127 | | Metrics 128 | |-------------------------------------------------------------------------- 129 | | 130 | | Here you can configure how many snapshots should be kept to display in 131 | | the metrics graph. This will get used in combination with Horizon's 132 | | `horizon:snapshot` schedule to define how long to retain metrics. 133 | | 134 | */ 135 | 136 | 'metrics' => [ 137 | 'trim_snapshots' => [ 138 | 'job' => 24, 139 | 'queue' => 24, 140 | ], 141 | ], 142 | 143 | /* 144 | |-------------------------------------------------------------------------- 145 | | Fast Termination 146 | |-------------------------------------------------------------------------- 147 | | 148 | | When this option is enabled, Horizon's "terminate" command will not 149 | | wait on all of the workers to terminate unless the --wait option 150 | | is provided. Fast termination can shorten deployment delay by 151 | | allowing a new instance of Horizon to start while the last 152 | | instance will continue to terminate each of its workers. 153 | | 154 | */ 155 | 156 | 'fast_termination' => false, 157 | 158 | /* 159 | |-------------------------------------------------------------------------- 160 | | Memory Limit (MB) 161 | |-------------------------------------------------------------------------- 162 | | 163 | | This value describes the maximum amount of memory the Horizon master 164 | | supervisor may consume before it is terminated and restarted. For 165 | | configuring these limits on your workers, see the next section. 166 | | 167 | */ 168 | 169 | 'memory_limit' => 64, 170 | 171 | /* 172 | |-------------------------------------------------------------------------- 173 | | Queue Worker Configuration 174 | |-------------------------------------------------------------------------- 175 | | 176 | | Here you may define the queue worker settings used by your application 177 | | in all environments. These supervisors and settings handle all your 178 | | queued jobs and will be provisioned by Horizon during deployment. 179 | | 180 | */ 181 | 182 | 'defaults' => [ 183 | 'supervisor-1' => [ 184 | 'connection' => 'redis', 185 | 'queue' => ['default'], 186 | 'balance' => 'auto', 187 | 'autoScalingStrategy' => 'time', 188 | 'maxProcesses' => 1, 189 | 'maxTime' => 0, 190 | 'maxJobs' => 0, 191 | 'memory' => 128, 192 | 'tries' => 1, 193 | 'timeout' => 60, 194 | 'nice' => 0, 195 | ], 196 | ], 197 | 198 | 'environments' => [ 199 | 'production' => [ 200 | 'supervisor-1' => [ 201 | 'maxProcesses' => 10, 202 | 'balanceMaxShift' => 1, 203 | 'balanceCooldown' => 3, 204 | ], 205 | ], 206 | 207 | 'local' => [ 208 | 'supervisor-1' => [ 209 | 'maxProcesses' => 3, 210 | ], 211 | ], 212 | ], 213 | ]; 214 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Deprecations Log Channel 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This option controls the log channel that should be used to log warnings 28 | | regarding deprecated PHP and library features. This allows you to get 29 | | your application ready for upcoming major versions of dependencies. 30 | | 31 | */ 32 | 33 | 'deprecations' => [ 34 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 35 | 'trace' => false, 36 | ], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Log Channels 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Here you may configure the log channels for your application. Out of 44 | | the box, Laravel uses the Monolog PHP logging library. This gives 45 | | you a variety of powerful log handlers / formatters to utilize. 46 | | 47 | | Available Drivers: "single", "daily", "slack", "syslog", 48 | | "errorlog", "monolog", 49 | | "custom", "stack" 50 | | 51 | */ 52 | 53 | 'channels' => [ 54 | 'stack' => [ 55 | 'driver' => 'stack', 56 | 'channels' => ['single'], 57 | 'ignore_exceptions' => false, 58 | ], 59 | 60 | 'single' => [ 61 | 'driver' => 'single', 62 | 'path' => storage_path('logs/laravel.log'), 63 | 'level' => env('LOG_LEVEL', 'debug'), 64 | ], 65 | 66 | 'daily' => [ 67 | 'driver' => 'daily', 68 | 'path' => storage_path('logs/laravel.log'), 69 | 'level' => env('LOG_LEVEL', 'debug'), 70 | 'days' => 14, 71 | ], 72 | 73 | 'slack' => [ 74 | 'driver' => 'slack', 75 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 76 | 'username' => 'Laravel Log', 77 | 'emoji' => ':boom:', 78 | 'level' => env('LOG_LEVEL', 'critical'), 79 | ], 80 | 81 | 'papertrail' => [ 82 | 'driver' => 'monolog', 83 | 'level' => env('LOG_LEVEL', 'debug'), 84 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 85 | 'handler_with' => [ 86 | 'host' => env('PAPERTRAIL_URL'), 87 | 'port' => env('PAPERTRAIL_PORT'), 88 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 89 | ], 90 | ], 91 | 92 | 'stderr' => [ 93 | 'driver' => 'monolog', 94 | 'level' => env('LOG_LEVEL', 'debug'), 95 | 'handler' => StreamHandler::class, 96 | 'formatter' => env('LOG_STDERR_FORMATTER'), 97 | 'with' => [ 98 | 'stream' => 'php://stderr', 99 | ], 100 | ], 101 | 102 | 'syslog' => [ 103 | 'driver' => 'syslog', 104 | 'level' => env('LOG_LEVEL', 'debug'), 105 | 'facility' => LOG_USER, 106 | ], 107 | 108 | 'errorlog' => [ 109 | 'driver' => 'errorlog', 110 | 'level' => env('LOG_LEVEL', 'debug'), 111 | ], 112 | 113 | 'null' => [ 114 | 'driver' => 'monolog', 115 | 'handler' => NullHandler::class, 116 | ], 117 | 118 | 'emergency' => [ 119 | 'path' => storage_path('logs/laravel.log'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 32 | | "postmark", "log", "array", "failover" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'local_domain' => env('MAIL_EHLO_DOMAIN'), 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | // 'client' => [ 55 | // 'timeout' => 5, 56 | // ], 57 | ], 58 | 59 | 'postmark' => [ 60 | 'transport' => 'postmark', 61 | // 'client' => [ 62 | // 'timeout' => 5, 63 | // ], 64 | ], 65 | 66 | 'sendmail' => [ 67 | 'transport' => 'sendmail', 68 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 69 | ], 70 | 71 | 'log' => [ 72 | 'transport' => 'log', 73 | 'channel' => env('MAIL_LOG_CHANNEL'), 74 | ], 75 | 76 | 'array' => [ 77 | 'transport' => 'array', 78 | ], 79 | 80 | 'failover' => [ 81 | 'transport' => 'failover', 82 | 'mailers' => [ 83 | 'smtp', 84 | 'log', 85 | ], 86 | ], 87 | ], 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Global "From" Address 92 | |-------------------------------------------------------------------------- 93 | | 94 | | You may wish for all e-mails sent by your application to be sent from 95 | | the same address. Here, you may specify a name and address that is 96 | | used globally for all e-mails that are sent by your application. 97 | | 98 | */ 99 | 100 | 'from' => [ 101 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 102 | 'name' => env('MAIL_FROM_NAME', 'Example'), 103 | ], 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Markdown Mail Settings 108 | |-------------------------------------------------------------------------- 109 | | 110 | | If you are using Markdown based email rendering, you may configure your 111 | | theme and component paths here, allowing you to customize the design 112 | | of the emails. Or, you may simply stick with the Laravel defaults! 113 | | 114 | */ 115 | 116 | 'markdown' => [ 117 | 'theme' => 'default', 118 | 119 | 'paths' => [ 120 | resource_path('views/vendor/mail'), 121 | ], 122 | ], 123 | 124 | ]; 125 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | 'after_commit' => false, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | 'block_for' => 0, 51 | 'after_commit' => false, 52 | ], 53 | 54 | 'sqs' => [ 55 | 'driver' => 'sqs', 56 | 'key' => env('AWS_ACCESS_KEY_ID'), 57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 59 | 'queue' => env('SQS_QUEUE', 'default'), 60 | 'suffix' => env('SQS_SUFFIX'), 61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 62 | 'after_commit' => false, 63 | ], 64 | 65 | 'redis' => [ 66 | 'driver' => 'redis', 67 | 'connection' => 'default', 68 | 'queue' => env('REDIS_QUEUE', 'default'), 69 | 'retry_after' => 90, 70 | 'block_for' => null, 71 | 'after_commit' => false, 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Failed Queue Jobs 79 | |-------------------------------------------------------------------------- 80 | | 81 | | These options configure the behavior of failed queue job logging so you 82 | | can control which database and table are used to store the jobs that 83 | | have failed. You may change them to any database / table you wish. 84 | | 85 | */ 86 | 87 | 'failed' => [ 88 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 89 | 'database' => env('DB_CONNECTION', 'mysql'), 90 | 'table' => 'failed_jobs', 91 | ], 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /config/request-docs.php: -------------------------------------------------------------------------------- 1 | true, 5 | // change it to true will make lrd to throw exception if rules in request class need to be changed 6 | // keep it false 7 | 'debug' => false, 8 | 9 | /* 10 | * Route where request docs will be served from laravel app. 11 | * localhost:8080/request-docs 12 | */ 13 | 'url' => 'request-docs', 14 | 'middlewares' => [ 15 | // \Rakutentech\LaravelRequestDocs\NotFoundWhenProduction::class, 16 | ], 17 | 18 | //Use only routes where ->uri start with next string Using Str::startWith( . e.g. - /api/mobile 19 | 'only_route_uri_start_with' => '', 20 | 21 | 'hide_matching' => [ 22 | '#^telescope#', 23 | '#^docs#', 24 | '#^request-docs#', 25 | '#^api-docs#', 26 | '#^sanctum#', 27 | '#^_ignition#', 28 | '#^_tt#', 29 | ], 30 | 31 | 'hide_meta_data' => false, 32 | 'hide_sql_data' => false, 33 | 'hide_logs_data' => false, 34 | 'hide_models_data' => false, 35 | 36 | // https://github.com/rakutentech/laravel-request-docs/pull/92 37 | // When rules are put in other method than rules() 38 | 'rules_methods' => [ 39 | 'rules' 40 | ], 41 | // Can be overridden as // @LRDresponses 200|400|401 42 | 'default_responses' => [ "200", "400", "401", "403", "404", "405", "422", "429", "500", "503"], 43 | 44 | // By default, LRD group your routes by the first /path. 45 | // This is a set of regex to group your routes by prefix. 46 | 'group_by' => [ 47 | 'uri_patterns' => [ 48 | '^api/v[\d]+/', // `/api/v1/users/store` group as `/api/v1/users`. 49 | '^api/', // `/api/users/store` group as `/api/users`. 50 | ] 51 | ], 52 | 53 | // No need to touch below 54 | // open api config 55 | // used to generate open api json 56 | 'open_api' => [ 57 | // default version that this library provides 58 | 'version' => '3.0.0', 59 | // changeable 60 | 'document_version' => '1.0.0', 61 | // license that you want to display 62 | 'license' => 'Apache 2.0', 63 | 'license_url' => 'https://www.apache.org/licenses/LICENSE-2.0.html', 64 | 'server_url' => env('APP_URL', 'http://localhost'), 65 | 66 | // for now putting default responses for all. This can be changed later based on specific needs 67 | 'responses' => [ 68 | '200' => [ 69 | 'description' => 'Successful operation', 70 | 'content' => [ 71 | 'application/json' => [ 72 | 'schema' => [ 73 | 'type' => 'object', 74 | ], 75 | ], 76 | ], 77 | ], 78 | '400' => [ 79 | 'description' => 'Bad Request', 80 | 'content' => [ 81 | 'application/json' => [ 82 | 'schema' => [ 83 | 'type' => 'object', 84 | ], 85 | ], 86 | ], 87 | ], 88 | '401' => [ 89 | 'description' => 'Unauthorized', 90 | 'content' => [ 91 | 'application/json' => [ 92 | 'schema' => [ 93 | 'type' => 'object', 94 | ], 95 | ], 96 | ], 97 | ], 98 | '403' => [ 99 | 'description' => 'Forbidden', 100 | 'content' => [ 101 | 'application/json' => [ 102 | 'schema' => [ 103 | 'type' => 'object', 104 | ], 105 | ], 106 | ], 107 | ], 108 | '404' => [ 109 | 'description' => 'Not Found', 110 | 'content' => [ 111 | 'application/json' => [ 112 | 'schema' => [ 113 | 'type' => 'object', 114 | ], 115 | ], 116 | ], 117 | ], 118 | '422' => [ 119 | 'description' => 'Unprocessable Entity', 120 | 'content' => [ 121 | 'application/json' => [ 122 | 'schema' => [ 123 | 'type' => 'object', 124 | ], 125 | ], 126 | ], 127 | ], 128 | '500' => [ 129 | 'description' => 'Internal Server Error', 130 | 'content' => [ 131 | 'application/json' => [ 132 | 'schema' => [ 133 | 'type' => 'object', 134 | ], 135 | ], 136 | ], 137 | ], 138 | 'default' => [ 139 | 'description' => 'Unexpected error', 140 | 'content' => [ 141 | 'application/json' => [ 142 | 'schema' => [ 143 | 'type' => 'object', 144 | ], 145 | ], 146 | ], 147 | ], 148 | ], 149 | ], 150 | ]; 151 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort() 22 | ))), 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Sanctum Guards 27 | |-------------------------------------------------------------------------- 28 | | 29 | | This array contains the authentication guards that will be checked when 30 | | Sanctum is trying to authenticate a request. If none of these guards 31 | | are able to authenticate the request, Sanctum will use the bearer 32 | | token that's present on an incoming request for authentication. 33 | | 34 | */ 35 | 36 | 'guard' => ['web'], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Expiration Minutes 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This value controls the number of minutes until an issued token will be 44 | | considered expired. If this value is null, personal access tokens do 45 | | not expire. This won't tweak the lifetime of first-party sessions. 46 | | 47 | */ 48 | 49 | 'expiration' => 10, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Sanctum Middleware 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When authenticating your first-party SPA with Sanctum you may need to 57 | | customize some of the middleware Sanctum uses while processing the 58 | | request. You may change the middleware listed below as required. 59 | | 60 | */ 61 | 62 | 'middleware' => [ 63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION'), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | While using one of the framework's cache driven session backends you may 96 | | list a cache store that should be used for these sessions. This value 97 | | must match with one of the application's configured cache "stores". 98 | | 99 | | Affects: "apc", "dynamodb", "memcached", "redis" 100 | | 101 | */ 102 | 103 | 'store' => env('SESSION_STORE'), 104 | 105 | /* 106 | |-------------------------------------------------------------------------- 107 | | Session Sweeping Lottery 108 | |-------------------------------------------------------------------------- 109 | | 110 | | Some session drivers must manually sweep their storage location to get 111 | | rid of old sessions from storage. Here are the chances that it will 112 | | happen on a given request. By default, the odds are 2 out of 100. 113 | | 114 | */ 115 | 116 | 'lottery' => [2, 100], 117 | 118 | /* 119 | |-------------------------------------------------------------------------- 120 | | Session Cookie Name 121 | |-------------------------------------------------------------------------- 122 | | 123 | | Here you may change the name of the cookie used to identify a session 124 | | instance by ID. The name specified here will get used every time a 125 | | new session cookie is created by the framework for every driver. 126 | | 127 | */ 128 | 129 | 'cookie' => env( 130 | 'SESSION_COOKIE', 131 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 132 | ), 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Session Cookie Path 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The session cookie path determines the path for which the cookie will 140 | | be regarded as available. Typically, this will be the root path of 141 | | your application but you are free to change this when necessary. 142 | | 143 | */ 144 | 145 | 'path' => '/', 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | Session Cookie Domain 150 | |-------------------------------------------------------------------------- 151 | | 152 | | Here you may change the domain of the cookie used to identify a session 153 | | in your application. This will determine which domains the cookie is 154 | | available to in your application. A sensible default has been set. 155 | | 156 | */ 157 | 158 | 'domain' => env('SESSION_DOMAIN'), 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | HTTPS Only Cookies 163 | |-------------------------------------------------------------------------- 164 | | 165 | | By setting this option to true, session cookies will only be sent back 166 | | to the server if the browser has a HTTPS connection. This will keep 167 | | the cookie from being sent to you when it can't be done securely. 168 | | 169 | */ 170 | 171 | 'secure' => env('SESSION_SECURE_COOKIE'), 172 | 173 | /* 174 | |-------------------------------------------------------------------------- 175 | | HTTP Access Only 176 | |-------------------------------------------------------------------------- 177 | | 178 | | Setting this value to true will prevent JavaScript from accessing the 179 | | value of the cookie and the cookie will only be accessible through 180 | | the HTTP protocol. You are free to modify this option if needed. 181 | | 182 | */ 183 | 184 | 'http_only' => true, 185 | 186 | /* 187 | |-------------------------------------------------------------------------- 188 | | Same-Site Cookies 189 | |-------------------------------------------------------------------------- 190 | | 191 | | This option determines how your cookies behave when cross-site requests 192 | | take place, and can be used to mitigate CSRF attacks. By default, we 193 | | will set this value to "lax" since this is a secure default value. 194 | | 195 | | Supported: "lax", "strict", "none", null 196 | | 197 | */ 198 | 199 | 'same_site' => 'lax', 200 | 201 | ]; 202 | -------------------------------------------------------------------------------- /config/telescope.php: -------------------------------------------------------------------------------- 1 | env('TELESCOPE_DOMAIN'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Telescope Path 24 | |-------------------------------------------------------------------------- 25 | | 26 | | This is the URI path where Telescope will be accessible from. Feel free 27 | | to change this path to anything you like. Note that the URI will not 28 | | affect the paths of its internal API that aren't exposed to users. 29 | | 30 | */ 31 | 32 | 'path' => env('TELESCOPE_PATH', 'telescope'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Telescope Storage Driver 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This configuration options determines the storage driver that will 40 | | be used to store Telescope's data. In addition, you may set any 41 | | custom options as needed by the particular driver you choose. 42 | | 43 | */ 44 | 45 | 'driver' => env('TELESCOPE_DRIVER', 'database'), 46 | 47 | 'storage' => [ 48 | 'database' => [ 49 | 'connection' => env('DB_CONNECTION', 'mysql'), 50 | 'chunk' => 1000, 51 | ], 52 | ], 53 | 54 | /* 55 | |-------------------------------------------------------------------------- 56 | | Telescope Master Switch 57 | |-------------------------------------------------------------------------- 58 | | 59 | | This option may be used to disable all Telescope watchers regardless 60 | | of their individual configuration, which simply provides a single 61 | | and convenient way to enable or disable Telescope data storage. 62 | | 63 | */ 64 | 65 | 'enabled' => env('TELESCOPE_ENABLED', true), 66 | 67 | /* 68 | |-------------------------------------------------------------------------- 69 | | Telescope Route Middleware 70 | |-------------------------------------------------------------------------- 71 | | 72 | | These middleware will be assigned to every Telescope route, giving you 73 | | the chance to add your own middleware to this list or change any of 74 | | the existing middleware. Or, you can simply stick with this list. 75 | | 76 | */ 77 | 78 | 'middleware' => [ 79 | 'web', 80 | Authorize::class, 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Allowed / Ignored Paths & Commands 86 | |-------------------------------------------------------------------------- 87 | | 88 | | The following array lists the URI paths and Artisan commands that will 89 | | not be watched by Telescope. In addition to this list, some Laravel 90 | | commands, like migrations and queue commands, are always ignored. 91 | | 92 | */ 93 | 94 | 'only_paths' => [ 95 | // 'api/*' 96 | ], 97 | 98 | 'ignore_paths' => [ 99 | 'nova-api*', 100 | ], 101 | 102 | 'ignore_commands' => [ 103 | // 104 | ], 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Telescope Watchers 109 | |-------------------------------------------------------------------------- 110 | | 111 | | The following array lists the "watchers" that will be registered with 112 | | Telescope. The watchers gather the application's profile data when 113 | | a request or task is executed. Feel free to customize this list. 114 | | 115 | */ 116 | 117 | 'watchers' => [ 118 | Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true), 119 | 120 | Watchers\CacheWatcher::class => [ 121 | 'enabled' => env('TELESCOPE_CACHE_WATCHER', true), 122 | 'hidden' => [], 123 | ], 124 | 125 | Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true), 126 | 127 | Watchers\CommandWatcher::class => [ 128 | 'enabled' => env('TELESCOPE_COMMAND_WATCHER', true), 129 | 'ignore' => [], 130 | ], 131 | 132 | Watchers\DumpWatcher::class => [ 133 | 'enabled' => env('TELESCOPE_DUMP_WATCHER', true), 134 | 'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false), 135 | ], 136 | 137 | Watchers\EventWatcher::class => [ 138 | 'enabled' => env('TELESCOPE_EVENT_WATCHER', true), 139 | 'ignore' => [], 140 | ], 141 | 142 | Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true), 143 | 144 | Watchers\GateWatcher::class => [ 145 | 'enabled' => env('TELESCOPE_GATE_WATCHER', true), 146 | 'ignore_abilities' => [], 147 | 'ignore_packages' => true, 148 | 'ignore_paths' => [], 149 | ], 150 | 151 | Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true), 152 | 153 | Watchers\LogWatcher::class => [ 154 | 'enabled' => env('TELESCOPE_LOG_WATCHER', true), 155 | 'level' => 'error', 156 | ], 157 | 158 | Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true), 159 | 160 | Watchers\ModelWatcher::class => [ 161 | 'enabled' => env('TELESCOPE_MODEL_WATCHER', true), 162 | 'events' => ['eloquent.*'], 163 | 'hydrations' => true, 164 | ], 165 | 166 | Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true), 167 | 168 | Watchers\QueryWatcher::class => [ 169 | 'enabled' => env('TELESCOPE_QUERY_WATCHER', true), 170 | 'ignore_packages' => true, 171 | 'ignore_paths' => [], 172 | 'slow' => 100, 173 | ], 174 | 175 | Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true), 176 | 177 | Watchers\RequestWatcher::class => [ 178 | 'enabled' => env('TELESCOPE_REQUEST_WATCHER', true), 179 | 'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64), 180 | 'ignore_http_methods' => [], 181 | 'ignore_status_codes' => [], 182 | ], 183 | 184 | Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true), 185 | Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true), 186 | ], 187 | ]; 188 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /database/factories/CategoryFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class CategoryFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | $user = User::factory()->create(); 21 | 22 | return [ 23 | 'name' => fake()->name(), 24 | 'user_id' => User::factory(), 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /database/factories/ProductFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class ProductFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'name' => fake()->name(), 22 | 'price' => fake()->numberBetween(1, 100), 23 | 'user_id' => User::factory(), 24 | ]; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class UserFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'name' => fake()->name(), 22 | 'email' => fake()->unique()->safeEmail(), 23 | 'email_verified_at' => now(), 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 25 | 'remember_token' => Str::random(10), 26 | ]; 27 | } 28 | 29 | /** 30 | * Indicate that the model's email address should be unverified. 31 | */ 32 | public function unverified(): static 33 | { 34 | return $this->state(fn (array $attributes) => [ 35 | 'email_verified_at' => null, 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('users'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/migrations/2018_08_08_100000_create_telescope_entries_table.php: -------------------------------------------------------------------------------- 1 | getConnection()); 23 | 24 | $schema->create('telescope_entries', function (Blueprint $table) { 25 | $table->bigIncrements('sequence'); 26 | $table->uuid('uuid'); 27 | $table->uuid('batch_id'); 28 | $table->string('family_hash')->nullable(); 29 | $table->boolean('should_display_on_index')->default(true); 30 | $table->string('type', 20); 31 | $table->longText('content'); 32 | $table->dateTime('created_at')->nullable(); 33 | 34 | $table->unique('uuid'); 35 | $table->index('batch_id'); 36 | $table->index('family_hash'); 37 | $table->index('created_at'); 38 | $table->index(['type', 'should_display_on_index']); 39 | }); 40 | 41 | $schema->create('telescope_entries_tags', function (Blueprint $table) { 42 | $table->uuid('entry_uuid'); 43 | $table->string('tag'); 44 | 45 | $table->index(['entry_uuid', 'tag']); 46 | $table->index('tag'); 47 | 48 | $table->foreign('entry_uuid') 49 | ->references('uuid') 50 | ->on('telescope_entries') 51 | ->onDelete('cascade'); 52 | }); 53 | 54 | $schema->create('telescope_monitoring', function (Blueprint $table) { 55 | $table->string('tag'); 56 | }); 57 | } 58 | 59 | /** 60 | * Reverse the migrations. 61 | */ 62 | public function down(): void 63 | { 64 | $schema = Schema::connection($this->getConnection()); 65 | 66 | $schema->dropIfExists('telescope_entries_tags'); 67 | $schema->dropIfExists('telescope_entries'); 68 | $schema->dropIfExists('telescope_monitoring'); 69 | } 70 | }; 71 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2023_03_06_095645_create_products_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 15 | $table->string('name'); 16 | $table->float('price'); 17 | $table->unsignedBigInteger('user_id'); 18 | $table->timestamps(); 19 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::table('products', function (Blueprint $table) { 29 | $table->dropForeign('user_id'); 30 | }); 31 | Schema::dropIfExists('products'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2023_03_06_095651_create_categories_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 16 | $table->string('name'); 17 | $table->unsignedBigInteger('user_id'); 18 | $table->timestamps(); 19 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::table('categories', function (Blueprint $table) { 29 | $table->dropForeign('user_id'); 30 | }); 31 | Schema::dropIfExists('categories'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2023_03_06_095659_create_category_product_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 16 | $table->unsignedBigInteger('category_id'); 17 | $table->unsignedBigInteger('product_id'); 18 | $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade'); 19 | $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade'); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::table('products', function (Blueprint $table) { 29 | $table->dropForeign('category_id'); 30 | $table->dropForeign('product_id'); 31 | }); 32 | Schema::dropIfExists('category_product'); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | 17 | // \App\Models\User::factory()->create([ 18 | // 'name' => 'Test User', 19 | // 'email' => 'test@example.com', 20 | // ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | laravel.test: 4 | build: 5 | context: ./vendor/laravel/sail/runtimes/8.2 6 | dockerfile: Dockerfile 7 | args: 8 | WWWGROUP: '${WWWGROUP}' 9 | image: sail-8.2/app 10 | extra_hosts: 11 | - 'host.docker.internal:host-gateway' 12 | ports: 13 | - '${APP_PORT:-80}:80' 14 | - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' 15 | environment: 16 | WWWUSER: '${WWWUSER}' 17 | LARAVEL_SAIL: 1 18 | XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' 19 | XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' 20 | volumes: 21 | - '.:/var/www/html' 22 | networks: 23 | - sail 24 | depends_on: 25 | - mysql 26 | - redis 27 | - meilisearch 28 | - mailpit 29 | - selenium 30 | mysql: 31 | image: 'mysql/mysql-server:8.0' 32 | ports: 33 | - '${FORWARD_DB_PORT:-3306}:3306' 34 | environment: 35 | MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' 36 | MYSQL_ROOT_HOST: '%' 37 | MYSQL_DATABASE: '${DB_DATABASE}' 38 | MYSQL_USER: '${DB_USERNAME}' 39 | MYSQL_PASSWORD: '${DB_PASSWORD}' 40 | MYSQL_ALLOW_EMPTY_PASSWORD: 1 41 | volumes: 42 | - 'sail-mysql:/var/lib/mysql' 43 | - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' 44 | networks: 45 | - sail 46 | healthcheck: 47 | test: 48 | - CMD 49 | - mysqladmin 50 | - ping 51 | - '-p${DB_PASSWORD}' 52 | retries: 3 53 | timeout: 5s 54 | redis: 55 | image: 'redis:alpine' 56 | ports: 57 | - '${FORWARD_REDIS_PORT:-6379}:6379' 58 | volumes: 59 | - 'sail-redis:/data' 60 | networks: 61 | - sail 62 | healthcheck: 63 | test: 64 | - CMD 65 | - redis-cli 66 | - ping 67 | retries: 3 68 | timeout: 5s 69 | meilisearch: 70 | image: 'getmeili/meilisearch:latest' 71 | ports: 72 | - '${FORWARD_MEILISEARCH_PORT:-7700}:7700' 73 | volumes: 74 | - 'sail-meilisearch:/meili_data' 75 | networks: 76 | - sail 77 | healthcheck: 78 | test: 79 | - CMD 80 | - wget 81 | - '--no-verbose' 82 | - '--spider' 83 | - 'http://localhost:7700/health' 84 | retries: 3 85 | timeout: 5s 86 | mailpit: 87 | image: 'axllent/mailpit:latest' 88 | ports: 89 | - '${FORWARD_MAILPIT_PORT:-1025}:1025' 90 | - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025' 91 | networks: 92 | - sail 93 | selenium: 94 | image: seleniarm/standalone-chromium 95 | extra_hosts: 96 | - 'host.docker.internal:host-gateway' 97 | volumes: 98 | - '/dev/shm:/dev/shm' 99 | networks: 100 | - sail 101 | networks: 102 | sail: 103 | driver: bridge 104 | volumes: 105 | sail-mysql: 106 | driver: local 107 | sail-redis: 108 | driver: local 109 | sail-meilisearch: 110 | driver: local 111 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "vite", 5 | "build": "vite build" 6 | }, 7 | "devDependencies": { 8 | "axios": "^1.1.2", 9 | "laravel-vite-plugin": "^0.7.2", 10 | "vite": "^4.0.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kvyaceslav/simple-laravel-api/ea7356e589dca66834c96f2074f20397c7beafc8/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/vendor/horizon/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kvyaceslav/simple-laravel-api/ea7356e589dca66834c96f2074f20397c7beafc8/public/vendor/horizon/img/favicon.png -------------------------------------------------------------------------------- /public/vendor/horizon/img/horizon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /public/vendor/horizon/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/app.js": "/app.js?id=45904d8bd75c65ee5c136a52a5e8ead6", 3 | "/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435", 4 | "/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5", 5 | "/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f", 6 | "/img/horizon.svg": "/img/horizon.svg?id=904d5b5185fefb09035384e15bfca765", 7 | "/img/sprite.svg": "/img/sprite.svg?id=afc4952b74895bdef3ab4ebe9adb746f" 8 | } 9 | -------------------------------------------------------------------------------- /public/vendor/telescope/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kvyaceslav/simple-laravel-api/ea7356e589dca66834c96f2074f20397c7beafc8/public/vendor/telescope/favicon.ico -------------------------------------------------------------------------------- /public/vendor/telescope/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/app.js": "/app.js?id=65e09ad17337bc012e95e6a52546ec50", 3 | "/app-dark.css": "/app-dark.css?id=b44bf369e5d39f6861be639ef866bf5a", 4 | "/app.css": "/app.css?id=41c5661581f2614180d6d33c17470f08" 5 | } 6 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kvyaceslav/simple-laravel-api/ea7356e589dca66834c96f2074f20397c7beafc8/resources/css/app.css -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 |
20 | @if (Route::has('login')) 21 |
22 | @auth 23 | Home 24 | @else 25 | Log in 26 | 27 | @if (Route::has('register')) 28 | Register 29 | @endif 30 | @endauth 31 |
32 | @endif 33 | 34 |
35 |
36 | 37 | 38 | 39 |
40 | 41 | 120 | 121 |
122 | 132 | 133 |
134 | Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}) 135 |
136 |
137 |
138 |
139 | 140 | 141 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | 'api.auth'], function () { 13 | Route::get('user', [LoginController::class, 'details']); 14 | Route::get('logout', [LoginController::class, 'logout']); 15 | 16 | Route::apiResource('product', ProductController::class); 17 | Route::apiResource('category', CategoryController::class); 18 | }); 19 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Feature/Api/CategoryControllerTest.php: -------------------------------------------------------------------------------- 1 | create(); 18 | 19 | $response = $this->actingAs($user)->get('api/category'); 20 | 21 | $response->assertStatus(Response::HTTP_OK); 22 | } 23 | 24 | /** 25 | * @return void 26 | */ 27 | public function test_store(): void 28 | { 29 | $user = User::factory()->create(); 30 | 31 | $response = $this->actingAs($user)->postJson('api/category', Category::factory()->raw()); 32 | 33 | $response->assertStatus(Response::HTTP_OK); 34 | } 35 | 36 | /** 37 | * @return void 38 | */ 39 | public function test_show(): void 40 | { 41 | $user = User::factory()->create(); 42 | 43 | $category = $user->categories()->create(Category::factory()->make()->toArray()); 44 | 45 | $response = $this->actingAs($user)->get('api/category/' . $category->id); 46 | 47 | $response->assertStatus(Response::HTTP_OK); 48 | } 49 | 50 | /** 51 | * @return void 52 | */ 53 | public function test_update(): void 54 | { 55 | $user = User::factory()->create(); 56 | 57 | $category = $user->categories()->create(Category::factory()->make()->toArray()); 58 | 59 | $response = $this->actingAs($user)->patchJson('api/category/' . $category->id, [ 60 | 'name' => fake()->name(), 61 | ]); 62 | 63 | $response->assertStatus(Response::HTTP_OK); 64 | } 65 | 66 | /** 67 | * @return void 68 | */ 69 | public function test_destroy(): void 70 | { 71 | $user = User::factory()->create(); 72 | 73 | $category = $user->categories()->create(Category::factory()->make()->toArray()); 74 | 75 | $response = $this->actingAs($user)->delete('api/category/' . $category->id); 76 | 77 | $response->assertStatus(Response::HTTP_OK); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/Feature/Api/LoginControllerTest.php: -------------------------------------------------------------------------------- 1 | create(); 23 | 24 | $response = $this->postJson('api/login', [ 25 | 'email' => $user->email, 26 | 'password' => 'password', 27 | ]); 28 | 29 | $response->assertStatus(Response::HTTP_OK); 30 | } 31 | 32 | /** 33 | * @return void 34 | */ 35 | public function test_logout(): void 36 | { 37 | $user = User::factory()->create(); 38 | 39 | $response = $this->actingAs($user)->get('api/logout'); 40 | 41 | $response->assertStatus(Response::HTTP_OK); 42 | } 43 | 44 | /** 45 | * @return void 46 | */ 47 | public function test_details(): void 48 | { 49 | $user = User::factory()->create(); 50 | 51 | $response = $this->actingAs($user)->get('api/user'); 52 | 53 | $response->assertStatus(Response::HTTP_OK); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/Feature/Api/ProductControllerTest.php: -------------------------------------------------------------------------------- 1 | create(); 18 | 19 | $response = $this->actingAs($user)->get('api/product'); 20 | 21 | $response->assertStatus(Response::HTTP_OK); 22 | } 23 | 24 | /** 25 | * @return void 26 | */ 27 | public function test_store(): void 28 | { 29 | $user = User::factory()->create(); 30 | 31 | $response = $this->actingAs($user)->postJson('api/product', Product::factory()->raw()); 32 | 33 | $response->assertStatus(Response::HTTP_OK); 34 | } 35 | 36 | /** 37 | * @return void 38 | */ 39 | public function test_show(): void 40 | { 41 | $user = User::factory()->create(); 42 | 43 | $product = $user->products()->create(Product::factory()->make()->toArray()); 44 | 45 | $response = $this->actingAs($user)->get('api/product/' . $product->id); 46 | 47 | $response->assertStatus(Response::HTTP_OK); 48 | } 49 | 50 | /** 51 | * @return void 52 | */ 53 | public function test_update(): void 54 | { 55 | $user = User::factory()->create(); 56 | 57 | $product = $user->products()->create(Product::factory()->make()->toArray()); 58 | 59 | $response = $this->actingAs($user)->patchJson('api/product/' . $product->id, [ 60 | 'name' => fake()->name(), 61 | 'price' => fake()->numberBetween(1, 100), 62 | ]); 63 | 64 | $response->assertStatus(Response::HTTP_OK); 65 | } 66 | 67 | /** 68 | * @return void 69 | */ 70 | public function test_destroy(): void 71 | { 72 | $user = User::factory()->create(); 73 | 74 | $product = $user->products()->create(Product::factory()->make()->toArray()); 75 | 76 | $response = $this->actingAs($user)->delete('api/product/' . $product->id); 77 | 78 | $response->assertStatus(Response::HTTP_OK); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /tests/Feature/Api/RegisterControllerTest.php: -------------------------------------------------------------------------------- 1 | faker()->password(); 22 | 23 | $response = $this->postJson('api/register', [ 24 | 'name' => $this->faker->name(), 25 | 'email' => $this->faker->email(), 26 | 'password' => $password, 27 | 'confirm_password' => $password, 28 | ]); 29 | 30 | $response->assertStatus(Response::HTTP_OK); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 |