├── .env.example ├── .github └── FUNDING.yml ├── .gitignore ├── api └── Users │ ├── Console │ └── AddUserCommand.php │ ├── Controllers │ └── UserController.php │ ├── Events │ ├── UserWasCreated.php │ ├── UserWasDeleted.php │ └── UserWasUpdated.php │ ├── Exceptions │ └── UserNotFoundException.php │ ├── Listeners │ └── SendEmailWelcome.php │ ├── Models │ ├── Permission.php │ ├── Role.php │ └── User.php │ ├── Observers │ └── UserObserver.php │ ├── Policies │ └── UserPolicy.php │ ├── Providers │ ├── UserEventServiceProvider.php │ └── UserServiceProvider.php │ ├── Repositories │ └── UserRepository.php │ ├── Requests │ ├── CreateUserRequest.php │ └── UpdateUserRequest.php │ ├── Services │ └── UserService.php │ └── routes.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filesystems.php ├── larapi.php ├── laratrust.php ├── logging.php ├── mail.php ├── passport.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ └── 2030_01_08_160033_laratrust_setup_tables.php └── seeders │ ├── DatabaseSeeder.php │ └── UsersTableSeeder.php ├── docker-compose.yml ├── infrastructure ├── Abstracts │ ├── ApiRequest.php │ ├── Controller.php │ ├── Event.php │ ├── Job.php │ ├── Model.php │ ├── Observer.php │ └── Repository.php ├── Api │ ├── Controllers │ │ └── DefaultApiController.php │ └── routes_public.php ├── Auth │ ├── Controllers │ │ ├── LoginController.php │ │ └── RegisterController.php │ ├── Exceptions │ │ └── InvalidCredentialsException.php │ ├── Requests │ │ ├── LoginRequest.php │ │ └── RegisterRequest.php │ ├── Services │ │ ├── LoginService.php │ │ └── RegisterService.php │ ├── routes.php │ └── routes_public.php ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Kernel.php │ └── Middlewares │ │ ├── AccessTokenChecker.php │ │ ├── EncryptCookies.php │ │ └── Logger.php ├── Logging │ └── SlackLogFormatter.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── LaratrustServiceProvider.php │ └── RouteServiceProvider.php └── Testing │ ├── CreatesApplication.php │ ├── Feature │ └── ExampleTest.php │ ├── TestCase.php │ └── Unit │ └── ExampleTest.php ├── phpunit.xml ├── pic.png ├── public ├── .htaccess ├── index.php └── robots.txt ├── readme.md ├── resources ├── lang │ └── en │ │ └── validation.php └── views │ └── .gitkeep ├── scripts ├── install-with-docker.sh └── install.sh ├── server.php └── storage ├── app ├── .gitignore └── public │ └── .gitignore ├── framework ├── .gitignore ├── cache │ └── .gitignore ├── sessions │ └── .gitignore └── views │ └── .gitignore └── logs └── .gitignore /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | APP_PORT=8080 7 | APP_SERVICE=server 8 | 9 | LOG_CHANNEL=stack 10 | LOG_SLACK_WEBHOOK_URL= 11 | 12 | DB_CONNECTION=mysql 13 | DB_HOST=mysql 14 | DB_PORT=3306 15 | DB_DATABASE=project-name 16 | DB_USERNAME=root 17 | DB_PASSWORD=secret 18 | 19 | BROADCAST_DRIVER=log 20 | CACHE_DRIVER=file 21 | QUEUE_DRIVER=redis 22 | QUEUE_CONNECTION=sync 23 | SESSION_DRIVER=file 24 | SESSION_LIFETIME=120 25 | 26 | REDIS_HOST=127.0.0.1 27 | REDIS_PASSWORD=null 28 | REDIS_PORT=6379 29 | 30 | MAIL_DRIVER=smtp 31 | MAIL_HOST=smtp.mailtrap.io 32 | MAIL_PORT=2525 33 | MAIL_USERNAME=null 34 | MAIL_PASSWORD=null 35 | MAIL_ENCRYPTION=null 36 | MAIL_FROM_ADDRESS=hello@example.com 37 | MAIL_FROM_NAME=Example 38 | 39 | PUSHER_APP_ID= 40 | PUSHER_APP_KEY= 41 | PUSHER_APP_SECRET= 42 | PUSHER_APP_CLUSTER=mt1 43 | 44 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 45 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 46 | 47 | PERSONAL_CLIENT_ID=1 48 | PERSONAL_CLIENT_SECRET= 49 | PASSWORD_CLIENT_ID=2 50 | PASSWORD_CLIENT_SECRET= 51 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | ko_fi: gentritabazi01 4 | custom: ['paypal.me/gentritabazi01'] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /public/storage 3 | Homestead.yaml 4 | Homestead.json 5 | .env 6 | *.DS_Store 7 | /storage/*.key 8 | .rnd 9 | .phpunit.result.cache -------------------------------------------------------------------------------- /api/Users/Console/AddUserCommand.php: -------------------------------------------------------------------------------- 1 | userRepository = $userRepository; 43 | } 44 | 45 | /** 46 | * Execute the console command. 47 | * 48 | * @return mixed 49 | */ 50 | public function handle() 51 | { 52 | $user = $this->userRepository->create([ 53 | 'first_name' => $this->argument('first_name'), 54 | 'last_name' => $this->argument('last_name'), 55 | 'email' => $this->argument('email'), 56 | 'password' => $this->argument('password') 57 | ]); 58 | 59 | $this->info(sprintf('A user was created with ID %s', $user->id)); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /api/Users/Controllers/UserController.php: -------------------------------------------------------------------------------- 1 | userService = $userService; 17 | } 18 | 19 | public function getAll() 20 | { 21 | $resourceOptions = $this->parseResourceOptions(); 22 | 23 | $sendData = $this->userService->getAll($resourceOptions); 24 | 25 | return $this->response($sendData); 26 | } 27 | 28 | public function getById($userId) 29 | { 30 | $resourceOptions = $this->parseResourceOptions(); 31 | 32 | $sendData['user'] = $this->userService->getById($userId, $resourceOptions); 33 | 34 | return $this->response($sendData); 35 | } 36 | 37 | public function create(CreateUserRequest $request) 38 | { 39 | $data = $request->validated(); 40 | 41 | $sendData['user'] = $this->userService->create($data); 42 | 43 | return $this->response($sendData, 201); 44 | } 45 | 46 | public function update($userId, UpdateUserRequest $request) 47 | { 48 | $data = $request->validated(); 49 | 50 | $sendData['user'] = $this->userService->update($userId, $data); 51 | 52 | return $this->response($sendData); 53 | } 54 | 55 | public function delete($userId) 56 | { 57 | $this->userService->delete($userId); 58 | 59 | return $this->response(null, 204); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /api/Users/Events/UserWasCreated.php: -------------------------------------------------------------------------------- 1 | user = $user; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /api/Users/Events/UserWasDeleted.php: -------------------------------------------------------------------------------- 1 | user = $user; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /api/Users/Events/UserWasUpdated.php: -------------------------------------------------------------------------------- 1 | user = $user; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /api/Users/Exceptions/UserNotFoundException.php: -------------------------------------------------------------------------------- 1 | user; 16 | 17 | // 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /api/Users/Models/Permission.php: -------------------------------------------------------------------------------- 1 | attributes['password'] = app('hash')->make($value); 52 | } 53 | 54 | /** 55 | * Get the name for the user. 56 | * 57 | * @return string 58 | */ 59 | public function getNameAttribute() 60 | { 61 | return $this->first_name. ' '. $this->last_name; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /api/Users/Observers/UserObserver.php: -------------------------------------------------------------------------------- 1 | id === $affectedUser->id; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /api/Users/Providers/UserEventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 20 | SendEmailWelcome::class 21 | ], 22 | 23 | UserWasUpdated::class => [ 24 | // 25 | ], 26 | 27 | UserWasDeleted::class => [ 28 | // 29 | ] 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /api/Users/Providers/UserServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->register(UserEventServiceProvider::class); 21 | } 22 | 23 | /** 24 | * Bootstrap any application services. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | // Observers 31 | User::observe(UserObserver::class); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /api/Users/Repositories/UserRepository.php: -------------------------------------------------------------------------------- 1 | getModel(); 18 | 19 | $user->fill($data); 20 | $user->save(); 21 | 22 | return $user; 23 | } 24 | 25 | public function update(User $user, array $data) 26 | { 27 | $user->fill($data); 28 | 29 | $user->save(); 30 | 31 | return $user; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /api/Users/Requests/CreateUserRequest.php: -------------------------------------------------------------------------------- 1 | 'required|email|unique:users,email', 13 | 'first_name' => 'required|string', 14 | 'last_name' => 'required|string', 15 | 'password' => 'required|string|min:8' 16 | ]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/Users/Requests/UpdateUserRequest.php: -------------------------------------------------------------------------------- 1 | 'filled|email|unique:users,email', 13 | 'first_name' => 'filled|string', 14 | 'last_name' => 'filled|string', 15 | 'password' => 'filled|string|min:8' 16 | ]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/Users/Services/UserService.php: -------------------------------------------------------------------------------- 1 | userRepository = $userRepository; 24 | $this->dispatcher = $dispatcher; 25 | } 26 | 27 | public function getAll($options = []) 28 | { 29 | return $this->userRepository->getWithCount($options); 30 | } 31 | 32 | public function getById($userId, array $options = []) 33 | { 34 | $user = $this->getRequestedUser($userId, $options); 35 | 36 | return $user; 37 | } 38 | 39 | public function create($data) 40 | { 41 | $user = $this->userRepository->create($data); 42 | 43 | $this->dispatcher->dispatch(new UserWasCreated($user)); 44 | 45 | return $user; 46 | } 47 | 48 | public function update($userId, array $data) 49 | { 50 | $user = $this->getRequestedUser($userId); 51 | 52 | if (Gate::denies('update-user', $user)) { 53 | throw new AccessDeniedHttpException('Cannot update this user.'); 54 | } 55 | 56 | $this->userRepository->update($user, $data); 57 | 58 | $this->dispatcher->dispatch(new UserWasUpdated($user)); 59 | } 60 | 61 | public function delete($userId) 62 | { 63 | $user = $this->getRequestedUser($userId, ['select' => ['id']]); 64 | 65 | $this->userRepository->delete($userId); 66 | 67 | $this->dispatcher->dispatch(new UserWasDeleted($user)); 68 | 69 | return $user; 70 | } 71 | 72 | private function getRequestedUser($userId, array $options = []) 73 | { 74 | $user = $this->userRepository->getById($userId, $options); 75 | 76 | if (is_null($user)) { 77 | throw new UserNotFoundException; 78 | } 79 | 80 | return $user; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /api/Users/routes.php: -------------------------------------------------------------------------------- 1 | get('/users', 'UserController@getAll'); 6 | $router->get('/users/{id}', 'UserController@getById'); 7 | $router->post('/users', 'UserController@create'); 8 | $router->put('/users/{id}', 'UserController@update'); 9 | $router->delete('/users/{id}', 'UserController@delete'); 10 | -------------------------------------------------------------------------------- /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 | Infrastructure\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | Infrastructure\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | Infrastructure\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 | "description": "Laravel 8", 4 | "keywords": ["laravel-8", "larapi"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": "^7.3|^8.0", 9 | "beyondcode/laravel-dump-server": "^1.7", 10 | "fideloper/proxy": "^4.2", 11 | "fruitcake/laravel-cors": "^2.0", 12 | "guzzlehttp/guzzle": "^7.0.1", 13 | "laravel/tinker": "^2.0", 14 | "laravel/framework": "^8.0", 15 | "laravel/passport": "^10.0", 16 | "one2tek/larapi": "^2.0.0", 17 | "santigarcor/laratrust": "^6.3" 18 | }, 19 | "require-dev": { 20 | "facade/ignition": "^2.3.6", 21 | "fakerphp/faker": "^1.9.1", 22 | "laravel/sail": "^1.0.0", 23 | "mockery/mockery": "^1.3.1", 24 | "nunomaduro/collision": "^5.0", 25 | "phpunit/phpunit": "^9.3" 26 | }, 27 | "autoload": { 28 | "psr-4": { 29 | "Api\\": "api/", 30 | "Infrastructure\\": "infrastructure/", 31 | "Database\\Factories\\": "database/factories/", 32 | "Database\\Seeders\\": "database/seeders/" 33 | } 34 | }, 35 | "extra": { 36 | "laravel": { 37 | "dont-discover": [ 38 | "santigarcor/laratrust" 39 | ] 40 | } 41 | }, 42 | "scripts": { 43 | "post-root-package-install": [ 44 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 45 | ], 46 | "post-create-project-cmd": [ 47 | "@php artisan key:generate --ansi" 48 | ], 49 | "post-autoload-dump": [ 50 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 51 | "@php artisan package:discover --ansi" 52 | ] 53 | }, 54 | "config": { 55 | "preferred-install": "dist", 56 | "sort-packages": true, 57 | "optimize-autoloader": true 58 | }, 59 | "minimum-stability": "dev", 60 | "prefer-stable": true 61 | } 62 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services your application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | your application so that it is used when running Artisan tasks. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. We have gone 64 | | ahead and set this to a sensible default for you out of the box. 65 | | 66 | */ 67 | 68 | 'timezone' => 'UTC', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by the translation service provider. You are free to set this value 77 | | to any of the locales which will be supported by the application. 78 | | 79 | */ 80 | 81 | 'locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Application Fallback Locale 86 | |-------------------------------------------------------------------------- 87 | | 88 | | The fallback locale determines the locale to use when the current one 89 | | is not available. You may change the value to correspond to any of 90 | | the language folders that are provided through your application. 91 | | 92 | */ 93 | 94 | 'fallback_locale' => 'en', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Encryption Key 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This key is used by the Illuminate encrypter service and should be set 102 | | to a random, 32 character string, otherwise these encrypted strings 103 | | will not be safe. Please do this before deploying an application! 104 | | 105 | */ 106 | 107 | 'key' => env('APP_KEY'), 108 | 109 | 'cipher' => 'AES-256-CBC', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Logging Configuration 114 | |-------------------------------------------------------------------------- 115 | | 116 | | Here you may configure the log settings for your application. Out of 117 | | the box, Laravel uses the Monolog PHP logging library. This gives 118 | | you a variety of powerful log handlers / formatters to utilize. 119 | | 120 | | Available Settings: "single", "daily", "syslog", "errorlog" 121 | | 122 | */ 123 | 124 | 'log' => env('APP_LOG', 'single'), 125 | 126 | /* 127 | |-------------------------------------------------------------------------- 128 | | Autoloaded Service Providers 129 | |-------------------------------------------------------------------------- 130 | | 131 | | The service providers listed here will be automatically loaded on the 132 | | request to your application. Feel free to add your own services to 133 | | this array to grant expanded functionality to your applications. 134 | | 135 | */ 136 | 137 | 'providers' => [ 138 | 139 | /* 140 | * Laravel Framework Service Providers... 141 | */ 142 | Illuminate\Auth\AuthServiceProvider::class, 143 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 144 | Illuminate\Bus\BusServiceProvider::class, 145 | Illuminate\Cache\CacheServiceProvider::class, 146 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 147 | Illuminate\Cookie\CookieServiceProvider::class, 148 | Illuminate\Database\DatabaseServiceProvider::class, 149 | Illuminate\Encryption\EncryptionServiceProvider::class, 150 | Illuminate\Filesystem\FilesystemServiceProvider::class, 151 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 152 | Illuminate\Hashing\HashServiceProvider::class, 153 | Illuminate\Mail\MailServiceProvider::class, 154 | Illuminate\Notifications\NotificationServiceProvider::class, 155 | Illuminate\Pagination\PaginationServiceProvider::class, 156 | Illuminate\Pipeline\PipelineServiceProvider::class, 157 | Illuminate\Queue\QueueServiceProvider::class, 158 | Illuminate\Redis\RedisServiceProvider::class, 159 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 160 | Illuminate\Session\SessionServiceProvider::class, 161 | Illuminate\Translation\TranslationServiceProvider::class, 162 | Illuminate\Validation\ValidationServiceProvider::class, 163 | Illuminate\View\ViewServiceProvider::class, 164 | 165 | /* 166 | * Packages Service Providers... 167 | */ 168 | Infrastructure\Providers\LaratrustServiceProvider::class, 169 | 170 | /* 171 | * Application Service Providers... 172 | */ 173 | Infrastructure\Providers\AppServiceProvider::class, 174 | Infrastructure\Providers\AuthServiceProvider::class, 175 | Infrastructure\Providers\EventServiceProvider::class, 176 | Infrastructure\Providers\RouteServiceProvider::class, 177 | Api\Users\Providers\UserServiceProvider::class 178 | ], 179 | 180 | /* 181 | |-------------------------------------------------------------------------- 182 | | Class Aliases 183 | |-------------------------------------------------------------------------- 184 | | 185 | | This array of class aliases will be registered when this application 186 | | is started. However, feel free to register as many as you wish as 187 | | the aliases are "lazy" loaded so they don't hinder performance. 188 | | 189 | */ 190 | 191 | 'aliases' => [ 192 | 193 | 'App' => Illuminate\Support\Facades\App::class, 194 | 'Arr' => Illuminate\Support\Arr::class, 195 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 196 | 'Auth' => Illuminate\Support\Facades\Auth::class, 197 | 'Blade' => Illuminate\Support\Facades\Blade::class, 198 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 199 | 'Bus' => Illuminate\Support\Facades\Bus::class, 200 | 'Cache' => Illuminate\Support\Facades\Cache::class, 201 | 'Config' => Illuminate\Support\Facades\Config::class, 202 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 203 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 204 | 'DB' => Illuminate\Support\Facades\DB::class, 205 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 206 | 'Event' => Illuminate\Support\Facades\Event::class, 207 | 'File' => Illuminate\Support\Facades\File::class, 208 | 'Gate' => Illuminate\Support\Facades\Gate::class, 209 | 'Hash' => Illuminate\Support\Facades\Hash::class, 210 | 'Http' => Illuminate\Support\Facades\Http::class, 211 | 'Lang' => Illuminate\Support\Facades\Lang::class, 212 | 'Log' => Illuminate\Support\Facades\Log::class, 213 | 'Mail' => Illuminate\Support\Facades\Mail::class, 214 | 'Notification' => Illuminate\Support\Facades\Notification::class, 215 | 'Password' => Illuminate\Support\Facades\Password::class, 216 | 'Queue' => Illuminate\Support\Facades\Queue::class, 217 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 218 | 'Redis' => Illuminate\Support\Facades\Redis::class, 219 | 'Request' => Illuminate\Support\Facades\Request::class, 220 | 'Response' => Illuminate\Support\Facades\Response::class, 221 | 'Route' => Illuminate\Support\Facades\Route::class, 222 | 'Schema' => Illuminate\Support\Facades\Schema::class, 223 | 'Session' => Illuminate\Support\Facades\Session::class, 224 | 'Storage' => Illuminate\Support\Facades\Storage::class, 225 | 'Str' => Illuminate\Support\Str::class, 226 | 'URL' => Illuminate\Support\Facades\URL::class, 227 | 'Validator' => Illuminate\Support\Facades\Validator::class, 228 | 'View' => Illuminate\Support\Facades\View::class, 229 | 230 | ], 231 | 232 | ]; 233 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'api', 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", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'passport', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => Api\Users\Models\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | Here you may set the options for resetting passwords including the view 85 | | that is your password reset e-mail. You may also set the name of the 86 | | table that maintains all of the reset tokens for your application. 87 | | 88 | | You may specify multiple password reset configurations if you have more 89 | | than one user table or model in the application and you want to have 90 | | separate password reset settings based on the specific user types. 91 | | 92 | | The expire time is the number of minutes that the reset token should be 93 | | considered valid. This security feature keeps tokens short-lived so 94 | | they have less time to be guessed. You may change this as needed. 95 | | 96 | */ 97 | 98 | 'passwords' => [ 99 | 'users' => [ 100 | 'provider' => 'users', 101 | 'email' => 'auth.emails.password', 102 | 'table' => 'password_resets', 103 | 'expire' => 60, 104 | ], 105 | ], 106 | 107 | ]; 108 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'pusher'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Broadcast Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the broadcast connections that will be used 24 | | to broadcast events to other systems or over websockets. Samples of 25 | | each available type of connection are provided inside this array. 26 | | 27 | */ 28 | 29 | 'connections' => [ 30 | 31 | 'pusher' => [ 32 | 'driver' => 'pusher', 33 | 'key' => env('PUSHER_KEY'), 34 | 'secret' => env('PUSHER_SECRET'), 35 | 'app_id' => env('PUSHER_APP_ID'), 36 | 'options' => [ 37 | // 38 | ], 39 | ], 40 | 41 | 'redis' => [ 42 | 'driver' => 'redis', 43 | 'connection' => 'default', 44 | ], 45 | 46 | 'log' => [ 47 | 'driver' => 'log', 48 | ], 49 | 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Cache Stores 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the cache "stores" for your application as 24 | | well as their drivers. You may even define multiple stores for the 25 | | same cache driver to group types of items stored in your caches. 26 | | 27 | */ 28 | 29 | 'stores' => [ 30 | 31 | 'apc' => [ 32 | 'driver' => 'apc', 33 | ], 34 | 35 | 'array' => [ 36 | 'driver' => 'array', 37 | ], 38 | 39 | 'database' => [ 40 | 'driver' => 'database', 41 | 'table' => 'cache', 42 | 'connection' => null, 43 | ], 44 | 45 | 'file' => [ 46 | 'driver' => 'file', 47 | 'path' => storage_path('framework/cache'), 48 | ], 49 | 50 | 'memcached' => [ 51 | 'driver' => 'memcached', 52 | 'servers' => [ 53 | [ 54 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 55 | 'port' => env('MEMCACHED_PORT', 11211), 56 | 'weight' => 100, 57 | ], 58 | ], 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | ], 65 | 66 | ], 67 | 68 | /* 69 | |-------------------------------------------------------------------------- 70 | | Cache Key Prefix 71 | |-------------------------------------------------------------------------- 72 | | 73 | | When utilizing a RAM based store such as APC or Memcached, there might 74 | | be other applications utilizing the same cache. So, we'll specify a 75 | | value to get prefixed to all our keys so we can avoid collisions. 76 | | 77 | */ 78 | 79 | 'prefix' => 'laravel', 80 | 81 | ]; 82 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['*'], 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'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'host' => env('DB_HOST', '127.0.0.1'), 45 | 'port' => env('DB_PORT', '3306'), 46 | 'database' => env('DB_DATABASE', 'forge'), 47 | 'username' => env('DB_USERNAME', 'forge'), 48 | 'password' => env('DB_PASSWORD', ''), 49 | 'unix_socket' => env('DB_SOCKET', ''), 50 | 'charset' => 'utf8mb4', 51 | 'collation' => 'utf8mb4_unicode_ci', 52 | 'prefix' => '', 53 | 'prefix_indexes' => true, 54 | 'strict' => true, 55 | 'engine' => null, 56 | ], 57 | 58 | 'pgsql' => [ 59 | 'driver' => 'pgsql', 60 | 'host' => env('DB_HOST', '127.0.0.1'), 61 | 'port' => env('DB_PORT', '5432'), 62 | 'database' => env('DB_DATABASE', 'forge'), 63 | 'username' => env('DB_USERNAME', 'forge'), 64 | 'password' => env('DB_PASSWORD', ''), 65 | 'charset' => 'utf8', 66 | 'prefix' => '', 67 | 'prefix_indexes' => true, 68 | 'schema' => 'public', 69 | 'sslmode' => 'prefer', 70 | ], 71 | 72 | 'sqlsrv' => [ 73 | 'driver' => 'sqlsrv', 74 | 'host' => env('DB_HOST', 'localhost'), 75 | 'port' => env('DB_PORT', '1433'), 76 | 'database' => env('DB_DATABASE', 'forge'), 77 | 'username' => env('DB_USERNAME', 'forge'), 78 | 'password' => env('DB_PASSWORD', ''), 79 | 'charset' => 'utf8', 80 | 'prefix' => '', 81 | 'prefix_indexes' => true, 82 | ], 83 | 84 | ], 85 | 86 | /* 87 | |-------------------------------------------------------------------------- 88 | | Migration Repository Table 89 | |-------------------------------------------------------------------------- 90 | | 91 | | This table keeps track of all the migrations that have already run for 92 | | your application. Using this information, we can determine which of 93 | | the migrations on disk haven't actually been run in the database. 94 | | 95 | */ 96 | 97 | 'migrations' => 'migrations', 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Redis Databases 102 | |-------------------------------------------------------------------------- 103 | | 104 | | Redis is an open source, fast, and advanced key-value store that also 105 | | provides a richer set of commands than a typical key-value systems 106 | | such as APC or Memcached. Laravel makes it easy to dig right in. 107 | | 108 | */ 109 | 110 | 'redis' => [ 111 | 112 | 'client' => 'predis', 113 | 114 | 'default' => [ 115 | 'host' => env('REDIS_HOST', '127.0.0.1'), 116 | 'password' => env('REDIS_PASSWORD', null), 117 | 'port' => env('REDIS_PORT', 6379), 118 | 'database' => env('REDIS_DB', 0), 119 | ], 120 | 121 | 'cache' => [ 122 | 'host' => env('REDIS_HOST', '127.0.0.1'), 123 | 'password' => env('REDIS_PASSWORD', null), 124 | 'port' => env('REDIS_PORT', 6379), 125 | 'database' => env('REDIS_CACHE_DB', 1), 126 | ], 127 | 128 | ], 129 | 130 | ]; -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 'local', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Default Cloud Filesystem Disk 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Many applications store files both locally and in the cloud. For this 26 | | reason, you may specify a default "cloud" driver here. This driver 27 | | will be bound as the Cloud disk implementation in the container. 28 | | 29 | */ 30 | 31 | 'cloud' => 's3', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Filesystem Disks 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here you may configure as many filesystem "disks" as you wish, and you 39 | | may even configure multiple disks of the same driver. Defaults have 40 | | been setup for each driver as an example of the required options. 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'visibility' => 'public', 55 | ], 56 | 57 | 's3' => [ 58 | 'driver' => 's3', 59 | 'key' => 'your-key', 60 | 'secret' => 'your-secret', 61 | 'region' => 'your-region', 62 | 'bucket' => 'your-bucket', 63 | ], 64 | 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /config/larapi.php: -------------------------------------------------------------------------------- 1 | 'api', 6 | 7 | 'extra_routes' => [ 8 | 'routes' => [ 9 | 'middleware' => [], 10 | 'namespace' => 'Controllers', 11 | 'prefix' => null 12 | ], 13 | 'routes_public' => [ 14 | 'middleware' => [], 15 | 'namespace' => 'Controllers', 16 | 'prefix' => null 17 | ], 18 | ], 19 | 20 | 'extra_routes_namespaces' => [ 21 | 'Api' => base_path() . DIRECTORY_SEPARATOR . 'api', 22 | 'Infrastructure' => base_path() . DIRECTORY_SEPARATOR . 'infrastructure' 23 | ], 24 | 25 | 'exceptions_formatters' => [ 26 | Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException::class => one2tek\larapi\ExceptionsFormatters\UnprocessableEntityHttpExceptionFormatter::class, 27 | Throwable::class => one2tek\larapi\ExceptionsFormatters\ExceptionFormatter::class 28 | ] 29 | 30 | ]; 31 | -------------------------------------------------------------------------------- /config/laratrust.php: -------------------------------------------------------------------------------- 1 | false, 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Which permissions and role checker to use. 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Defines if you want to use the roles and permissions checker. 21 | | Available: 22 | | - default: Check for the roles and permissions using the method that Laratrust 23 | has always used. 24 | | - query: Check for the roles and permissions using direct queries to the database. 25 | | This method doesn't support cache yet. 26 | | 27 | */ 28 | 'checker' => 'query', 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Cache 33 | |-------------------------------------------------------------------------- 34 | | 35 | | Manage Laratrust's cache configurations. It uses the driver defined in the 36 | | config/cache.php file. 37 | | 38 | */ 39 | 'cache' => [ 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Use cache in the package 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Defines if Laratrust will use Laravel's Cache to cache the roles and permissions. 46 | | NOTE: Currently the database check does not use cache. 47 | | 48 | */ 49 | 'enabled' => env('LARATRUST_ENABLE_CACHE', true), 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Time to store in cache Laratrust's roles and permissions. 54 | |-------------------------------------------------------------------------- 55 | | 56 | | Determines the time in SECONDS to store Laratrust's roles and permissions in the cache. 57 | | 58 | */ 59 | 'expiration_time' => 3600, 60 | ], 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Laratrust User Models 65 | |-------------------------------------------------------------------------- 66 | | 67 | | This is the array that contains the information of the user models. 68 | | This information is used in the add-trait command, for the roles and 69 | | permissions relationships with the possible user models, and the 70 | | administration panel to attach roles and permissions to the users. 71 | | 72 | | The key in the array is the name of the relationship inside the roles and permissions. 73 | | 74 | */ 75 | 'user_models' => [ 76 | 'users' => \Api\Users\Models\User::class, 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Laratrust Models 82 | |-------------------------------------------------------------------------- 83 | | 84 | | These are the models used by Laratrust to define the roles, permissions and teams. 85 | | If you want the Laratrust models to be in a different namespace or 86 | | to have a different name, you can do it here. 87 | | 88 | */ 89 | 'models' => [ 90 | 91 | 'role' => \Api\Users\Models\Role::class, 92 | 93 | 'permission' => \Api\Users\Models\Permission::class, 94 | 95 | /** 96 | * Will be used only if the teams functionality is enabled. 97 | */ 98 | 'team' => \App\Models\Team::class, 99 | ], 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Laratrust Tables 104 | |-------------------------------------------------------------------------- 105 | | 106 | | These are the tables used by Laratrust to store all the authorization data. 107 | | 108 | */ 109 | 'tables' => [ 110 | 111 | 'roles' => 'roles', 112 | 113 | 'permissions' => 'permissions', 114 | 115 | /** 116 | * Will be used only if the teams functionality is enabled. 117 | */ 118 | 'teams' => 'teams', 119 | 120 | 'role_user' => 'role_user', 121 | 122 | 'permission_user' => 'permission_user', 123 | 124 | 'permission_role' => 'permission_role', 125 | ], 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Laratrust Foreign Keys 130 | |-------------------------------------------------------------------------- 131 | | 132 | | These are the foreign keys used by laratrust in the intermediate tables. 133 | | 134 | */ 135 | 'foreign_keys' => [ 136 | /** 137 | * User foreign key on Laratrust's role_user and permission_user tables. 138 | */ 139 | 'user' => 'user_id', 140 | 141 | /** 142 | * Role foreign key on Laratrust's role_user and permission_role tables. 143 | */ 144 | 'role' => 'role_id', 145 | 146 | /** 147 | * Role foreign key on Laratrust's permission_user and permission_role tables. 148 | */ 149 | 'permission' => 'permission_id', 150 | 151 | /** 152 | * Role foreign key on Laratrust's role_user and permission_user tables. 153 | */ 154 | 'team' => 'team_id', 155 | ], 156 | 157 | /* 158 | |-------------------------------------------------------------------------- 159 | | Laratrust Middleware 160 | |-------------------------------------------------------------------------- 161 | | 162 | | This configuration helps to customize the Laratrust middleware behavior. 163 | | 164 | */ 165 | 'middleware' => [ 166 | /** 167 | * Define if the laratrust middleware are registered automatically in the service provider 168 | */ 169 | 'register' => true, 170 | 171 | /** 172 | * Method to be called in the middleware return case. 173 | * Available: abort|redirect 174 | */ 175 | 'handling' => 'abort', 176 | 177 | /** 178 | * Handlers for the unauthorized method in the middlewares. 179 | * The name of the handler must be the same as the handling. 180 | */ 181 | 'handlers' => [ 182 | /** 183 | * Aborts the execution with a 403 code and allows you to provide the response text 184 | */ 185 | 'abort' => [ 186 | 'code' => 403, 187 | 'message' => 'User does not have any of the necessary access rights.' 188 | ], 189 | 190 | /** 191 | * Redirects the user to the given url. 192 | * If you want to flash a key to the session, 193 | * you can do it by setting the key and the content of the message 194 | * If the message content is empty it won't be added to the redirection. 195 | */ 196 | 'redirect' => [ 197 | 'url' => '/home', 198 | 'message' => [ 199 | 'key' => 'error', 200 | 'content' => '' 201 | ] 202 | ] 203 | ] 204 | ], 205 | 206 | 'teams' => [ 207 | /* 208 | |-------------------------------------------------------------------------- 209 | | Use teams feature in the package 210 | |-------------------------------------------------------------------------- 211 | | 212 | | Defines if Laratrust will use the teams feature. 213 | | Please check the docs to see what you need to do in case you have the package already configured. 214 | | 215 | */ 216 | 'enabled' => false, 217 | 218 | /* 219 | |-------------------------------------------------------------------------- 220 | | Strict check for roles/permissions inside teams 221 | |-------------------------------------------------------------------------- 222 | | 223 | | Determines if a strict check should be done when checking if a role or permission 224 | | is attached inside a team. 225 | | If it's false, when checking a role/permission without specifying the team, 226 | | it will check only if the user has attached that role/permission ignoring the team. 227 | | 228 | */ 229 | 'strict_check' => false, 230 | ], 231 | 232 | /* 233 | |-------------------------------------------------------------------------- 234 | | Laratrust Magic 'isAbleTo' Method 235 | |-------------------------------------------------------------------------- 236 | | 237 | | Supported cases for the magic is able to method (Refer to the docs). 238 | | Available: camel_case|snake_case|kebab_case 239 | | 240 | */ 241 | 'magic_is_able_to_method_case' => 'kebab_case', 242 | 243 | /* 244 | |-------------------------------------------------------------------------- 245 | | Laratrust Panel 246 | |-------------------------------------------------------------------------- 247 | | 248 | | Section to manage everything related with the admin panel for the roles and permissions. 249 | | 250 | */ 251 | 'panel' => [ 252 | /* 253 | |-------------------------------------------------------------------------- 254 | | Laratrust Panel Register 255 | |-------------------------------------------------------------------------- 256 | | 257 | | This manages if routes used for the admin panel should be registered. 258 | | Turn this value to false if you don't want to use Laratrust admin panel 259 | | 260 | */ 261 | 'register' => false, 262 | 263 | /* 264 | |-------------------------------------------------------------------------- 265 | | Laratrust Panel Path 266 | |-------------------------------------------------------------------------- 267 | | 268 | | This is the URI path where Laratrust panel for roles and permissions 269 | | will be accessible from. 270 | | 271 | */ 272 | 'path' => 'laratrust', 273 | 274 | /* 275 | |-------------------------------------------------------------------------- 276 | | Laratrust Panel Path 277 | |-------------------------------------------------------------------------- 278 | | 279 | | The route where the go back link should point 280 | | 281 | */ 282 | 'go_back_route' => '/', 283 | 284 | /* 285 | |-------------------------------------------------------------------------- 286 | | Laratrust Panel Route Middleware 287 | |-------------------------------------------------------------------------- 288 | | 289 | | These middleware will get attached onto each Laratrust panel route. 290 | | 291 | */ 292 | 'middleware' => ['web'], 293 | 294 | /* 295 | |-------------------------------------------------------------------------- 296 | | Enable permissions assignment 297 | |-------------------------------------------------------------------------- 298 | | 299 | | Enable/Disable the permissions assignment to the users. 300 | | 301 | */ 302 | 'assign_permissions_to_user' => true, 303 | 304 | /* 305 | |-------------------------------------------------------------------------- 306 | | Add restriction to roles in the panel 307 | |-------------------------------------------------------------------------- 308 | | 309 | | Configure which roles can not be editable, deletable and removable. 310 | | To add a role to the restriction, use name of the role here. 311 | | 312 | */ 313 | 'roles_restrictions' => [ 314 | // The user won't be able to remove roles already assigned to users. 315 | 'not_removable' => [], 316 | 317 | // The user won't be able to edit the role and the permissions assigned. 318 | 'not_editable' => [], 319 | 320 | // The user won't be able to delete the role. 321 | 'not_deletable' => [], 322 | ], 323 | ] 324 | ]; 325 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Log Channels 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the log channels for your application. Out of 27 | | the box, Laravel uses the Monolog PHP logging library. This gives 28 | | you a variety of powerful log handlers / formatters to utilize. 29 | | 30 | | Available Drivers: "single", "daily", "slack", "syslog", 31 | | "errorlog", "monolog", 32 | | "custom", "stack" 33 | | 34 | */ 35 | 36 | 'channels' => [ 37 | 'stack' => [ 38 | 'driver' => 'stack', 39 | 'channels' => ['daily'], 40 | ], 41 | 42 | 'single' => [ 43 | 'driver' => 'single', 44 | 'path' => storage_path('logs/laravel.log'), 45 | 'level' => 'debug', 46 | ], 47 | 48 | 'daily' => [ 49 | 'driver' => 'daily', 50 | 'path' => storage_path('logs/laravel.log'), 51 | 'level' => 'debug', 52 | 'days' => 14, 53 | ], 54 | 55 | 'slack' => [ 56 | 'driver' => 'slack', 57 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 58 | 'tap' => [Infrastructure\Logging\SlackLogFormatter::class], 59 | 'username' => 'Laravel Log', 60 | 'emoji' => ':boom:', 61 | 'level' => 'debug', 62 | ], 63 | 64 | 'papertrail' => [ 65 | 'driver' => 'monolog', 66 | 'level' => 'debug', 67 | 'handler' => SyslogUdpHandler::class, 68 | 'handler_with' => [ 69 | 'host' => env('PAPERTRAIL_URL'), 70 | 'port' => env('PAPERTRAIL_PORT'), 71 | ], 72 | ], 73 | 74 | 'stderr' => [ 75 | 'driver' => 'monolog', 76 | 'handler' => StreamHandler::class, 77 | 'with' => [ 78 | 'stream' => 'php://stderr', 79 | ], 80 | ], 81 | 82 | 'syslog' => [ 83 | 'driver' => 'syslog', 84 | 'level' => 'debug', 85 | ], 86 | 87 | 'errorlog' => [ 88 | 'driver' => 'errorlog', 89 | 'level' => 'debug', 90 | ], 91 | ], 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /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", 32 | | "postmark", "log", "array" 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 | 'auth_mode' => null, 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | ], 59 | 60 | 'sendmail' => [ 61 | 'transport' => 'sendmail', 62 | 'path' => '/usr/sbin/sendmail -bs', 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | ], 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Global "From" Address 78 | |-------------------------------------------------------------------------- 79 | | 80 | | You may wish for all e-mails sent by your application to be sent from 81 | | the same address. Here, you may specify a name and address that is 82 | | used globally for all e-mails that are sent by your application. 83 | | 84 | */ 85 | 86 | 'from' => [ 87 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 88 | 'name' => env('MAIL_FROM_NAME', 'Example'), 89 | ], 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Markdown Mail Settings 94 | |-------------------------------------------------------------------------- 95 | | 96 | | If you are using Markdown based email rendering, you may configure your 97 | | theme and component paths here, allowing you to customize the design 98 | | of the emails. Or, you may simply stick with the Laravel defaults! 99 | | 100 | */ 101 | 102 | 'markdown' => [ 103 | 'theme' => 'default', 104 | 105 | 'paths' => [ 106 | resource_path('views/vendor/mail'), 107 | ], 108 | ], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /config/passport.php: -------------------------------------------------------------------------------- 1 | env('PASSPORT_PRIVATE_KEY'), 17 | 18 | 'public_key' => env('PASSPORT_PUBLIC_KEY'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Client UUIDs 23 | |-------------------------------------------------------------------------- 24 | | 25 | | By default, Passport uses auto-incrementing primary keys when assigning 26 | | IDs to clients. However, if Passport is installed using the provided 27 | | --uuids switch, this will be set to "true" and UUIDs will be used. 28 | | 29 | */ 30 | 31 | 'client_uuids' => false, 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Personal Access Client 36 | |-------------------------------------------------------------------------- 37 | | 38 | | If you enable client hashing, you should set the personal access client 39 | | ID and unhashed secret within your environment file. The values will 40 | | get used while issuing fresh personal access tokens to your users. 41 | | 42 | */ 43 | 44 | 'personal_access_client' => [ 45 | 'id' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_ID'), 46 | 'secret' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET'), 47 | ], 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Passport Storage Driver 52 | |-------------------------------------------------------------------------- 53 | | 54 | | This configuration value allows you to customize the storage options 55 | | for Passport, such as the database connection that should be used 56 | | by Passport's internal database models which store tokens, etc. 57 | | 58 | */ 59 | 60 | 'storage' => [ 61 | 'database' => [ 62 | 'connection' => env('DB_CONNECTION', 'mysql'), 63 | ], 64 | ], 65 | 66 | // Custom 67 | 'password_client_id' => env('PASSWORD_CLIENT_ID', null), 68 | 'password_client_secret' => env('PASSWORD_CLIENT_SECRET', null), 69 | 70 | ]; 71 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 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 | 'expire' => 60, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'ttr' => 60, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => 'your-public-key', 54 | 'secret' => 'your-secret-key', 55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 56 | 'queue' => 'your-queue-name', 57 | 'region' => 'us-east-1', 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'expire' => 60, 65 | ], 66 | 67 | ], 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Failed Queue Jobs 72 | |-------------------------------------------------------------------------- 73 | | 74 | | These options configure the behavior of failed queue job logging so you 75 | | can control which database and table are used to store the jobs that 76 | | have failed. You may change them to any database / table you wish. 77 | | 78 | */ 79 | 80 | 'failed' => [ 81 | 'database' => env('DB_CONNECTION', 'mysql'), 82 | 'table' => 'failed_jobs', 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Sweeping Lottery 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Some session drivers must manually sweep their storage location to get 94 | | rid of old sessions from storage. Here are the chances that it will 95 | | happen on a given request. By default, the odds are 2 out of 100. 96 | | 97 | */ 98 | 99 | 'lottery' => [2, 100], 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Name 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Here you may change the name of the cookie used to identify a session 107 | | instance by ID. The name specified here will get used every time a 108 | | new session cookie is created by the framework for every driver. 109 | | 110 | */ 111 | 112 | 'cookie' => 'laravel_session', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Path 117 | |-------------------------------------------------------------------------- 118 | | 119 | | The session cookie path determines the path for which the cookie will 120 | | be regarded as available. Typically, this will be the root path of 121 | | your application but you are free to change this when necessary. 122 | | 123 | */ 124 | 125 | 'path' => '/', 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Session Cookie Domain 130 | |-------------------------------------------------------------------------- 131 | | 132 | | Here you may change the domain of the cookie used to identify a session 133 | | in your application. This will determine which domains the cookie is 134 | | available to in your application. A sensible default has been set. 135 | | 136 | */ 137 | 138 | 'domain' => null, 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | HTTPS Only Cookies 143 | |-------------------------------------------------------------------------- 144 | | 145 | | By setting this option to true, session cookies will only be sent back 146 | | to the server if the browser has a HTTPS connection. This will keep 147 | | the cookie from being sent to you if it can not be done securely. 148 | | 149 | */ 150 | 151 | 'secure' => false, 152 | 153 | /* 154 | |-------------------------------------------------------------------------- 155 | | HTTP Access Only 156 | |-------------------------------------------------------------------------- 157 | | 158 | | Setting this value to true will prevent JavaScript from accessing the 159 | | value of the cookie and the cookie will only be accessible through 160 | | the HTTP protocol. You are free to modify this option if needed. 161 | | 162 | */ 163 | 164 | 'http_only' => true, 165 | 166 | ]; 167 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | realpath(base_path('resources/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' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | Str::random(10), 27 | 'last_name' => Str::random(10), 28 | 'email' => $this->faker->unique()->safeEmail, 29 | 'email_verified_at' => now(), 30 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 31 | 'remember_token' => Str::random(10), 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 17 | $table->string('first_name'); 18 | $table->string('last_name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('users'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 17 | $table->string('token')->index(); 18 | $table->timestamp('created_at'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('password_resets'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2030_01_08_160033_laratrust_setup_tables.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 19 | $table->string('name')->unique(); 20 | $table->string('display_name')->nullable(); 21 | $table->string('description')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | 25 | // Create table for storing permissions 26 | Schema::create('permissions', function (Blueprint $table) { 27 | $table->bigIncrements('id'); 28 | $table->string('name')->unique(); 29 | $table->string('display_name')->nullable(); 30 | $table->string('description')->nullable(); 31 | $table->timestamps(); 32 | }); 33 | 34 | // Create table for associating roles to users and teams (Many To Many Polymorphic) 35 | Schema::create('role_user', function (Blueprint $table) { 36 | $table->unsignedBigInteger('role_id'); 37 | $table->unsignedBigInteger('user_id'); 38 | $table->string('user_type'); 39 | 40 | $table->foreign('role_id')->references('id')->on('roles') 41 | ->onUpdate('cascade')->onDelete('cascade'); 42 | 43 | $table->primary(['user_id', 'role_id', 'user_type']); 44 | }); 45 | 46 | // Create table for associating permissions to users (Many To Many Polymorphic) 47 | Schema::create('permission_user', function (Blueprint $table) { 48 | $table->unsignedBigInteger('permission_id'); 49 | $table->unsignedBigInteger('user_id'); 50 | $table->string('user_type'); 51 | 52 | $table->foreign('permission_id')->references('id')->on('permissions') 53 | ->onUpdate('cascade')->onDelete('cascade'); 54 | 55 | $table->primary(['user_id', 'permission_id', 'user_type']); 56 | }); 57 | 58 | // Create table for associating permissions to roles (Many-to-Many) 59 | Schema::create('permission_role', function (Blueprint $table) { 60 | $table->unsignedBigInteger('permission_id'); 61 | $table->unsignedBigInteger('role_id'); 62 | 63 | $table->foreign('permission_id')->references('id')->on('permissions') 64 | ->onUpdate('cascade')->onDelete('cascade'); 65 | $table->foreign('role_id')->references('id')->on('roles') 66 | ->onUpdate('cascade')->onDelete('cascade'); 67 | 68 | $table->primary(['permission_id', 'role_id']); 69 | }); 70 | } 71 | 72 | /** 73 | * Reverse the migrations. 74 | * 75 | * @return void 76 | */ 77 | public function down() 78 | { 79 | Schema::dropIfExists('permission_user'); 80 | Schema::dropIfExists('permission_role'); 81 | Schema::dropIfExists('permissions'); 82 | Schema::dropIfExists('role_user'); 83 | Schema::dropIfExists('roles'); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /database/seeders/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | fill([ 21 | 'first_name' => Str::random(10), 22 | 'last_name' => Str::random(10), 23 | 'email' => Str::random(10). '@gmail.com', 24 | 'password' => 'secret', 25 | ]); 26 | 27 | $user->save(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # For more information: https://laravel.com/docs/sail 2 | version: "3" 3 | services: 4 | server: 5 | build: 6 | context: ./vendor/laravel/sail/runtimes/8.0 7 | dockerfile: Dockerfile 8 | args: 9 | WWWGROUP: "${WWWGROUP}" 10 | image: sail-7.4/app 11 | ports: 12 | - "${APP_PORT:-80}:80" 13 | environment: 14 | WWWUSER: "${WWWUSER}" 15 | LARAVEL_SAIL: 1 16 | volumes: 17 | - ".:/var/www/html" 18 | networks: 19 | - sail 20 | depends_on: 21 | - mysql 22 | - redis 23 | 24 | mysql: 25 | image: "mysql:8.0" 26 | ports: 27 | - "${FORWARD_DB_PORT:-3306}:3306" 28 | environment: 29 | MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}" 30 | MYSQL_DATABASE: "${DB_DATABASE}" 31 | MYSQL_USER: "${DB_USERNAME}" 32 | MYSQL_PASSWORD: "${DB_PASSWORD}" 33 | MYSQL_ALLOW_EMPTY_PASSWORD: "yes" 34 | volumes: 35 | - "sailmysql:/var/lib/mysql" 36 | healthcheck: 37 | test: ["CMD", "mysqladmin", "ping"] 38 | networks: 39 | - sail 40 | 41 | redis: 42 | image: "redis:alpine" 43 | ports: 44 | - "${FORWARD_REDIS_PORT:-6379}:6379" 45 | volumes: 46 | - "sailredis:/data" 47 | networks: 48 | - sail 49 | healthcheck: 50 | test: ["CMD", "redis-cli", "ping"] 51 | 52 | mailhog: 53 | image: "mailhog/mailhog:latest" 54 | ports: 55 | - "${FORWARD_MAILHOG_PORT:-1025}:1025" 56 | - "${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025" 57 | networks: 58 | - sail 59 | 60 | networks: 61 | sail: 62 | driver: bridge 63 | 64 | volumes: 65 | sailmysql: 66 | driver: local 67 | sailredis: 68 | driver: local 69 | -------------------------------------------------------------------------------- /infrastructure/Abstracts/ApiRequest.php: -------------------------------------------------------------------------------- 1 | errors()->toJson()); 15 | } 16 | 17 | protected function failedAuthorization() 18 | { 19 | throw new HttpException(403); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /infrastructure/Abstracts/Controller.php: -------------------------------------------------------------------------------- 1 | format('Y-m-d H:i:s'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /infrastructure/Abstracts/Observer.php: -------------------------------------------------------------------------------- 1 | config('app.name'), 13 | 'date' => date('Y-m-d'), 14 | 'timezone' => config('app.timezone'), 15 | 'laravel_version' => app()->version() 16 | ]; 17 | 18 | return $this->response($data); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /infrastructure/Api/routes_public.php: -------------------------------------------------------------------------------- 1 | get('/', 'DefaultApiController@index'); 6 | -------------------------------------------------------------------------------- /infrastructure/Auth/Controllers/LoginController.php: -------------------------------------------------------------------------------- 1 | loginService = $loginService; 16 | } 17 | 18 | public function login(LoginRequest $request) 19 | { 20 | $email = $request->get('email'); 21 | $password = $request->get('password'); 22 | 23 | return $this->response($this->loginService->attemptLogin($email, $password)); 24 | } 25 | 26 | public function refresh() 27 | { 28 | return $this->response($this->loginService->attemptRefresh()); 29 | } 30 | 31 | public function logout() 32 | { 33 | $this->loginService->logout(); 34 | 35 | return $this->response(null, 204); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /infrastructure/Auth/Controllers/RegisterController.php: -------------------------------------------------------------------------------- 1 | registerService = $registerService; 16 | } 17 | 18 | public function store(RegisterRequest $request) 19 | { 20 | $sendData = $this->registerService->store($request->validated()); 21 | 22 | return $this->response($sendData); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /infrastructure/Auth/Exceptions/InvalidCredentialsException.php: -------------------------------------------------------------------------------- 1 | 'required|email', 13 | 'password' => 'required' 14 | ]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /infrastructure/Auth/Requests/RegisterRequest.php: -------------------------------------------------------------------------------- 1 | 'required|email|unique:users,email', 13 | 'first_name' => 'required|string', 14 | 'last_name' => 'required|string', 15 | 'password' => 'required|string|min:8' 16 | ]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /infrastructure/Auth/Services/LoginService.php: -------------------------------------------------------------------------------- 1 | userRepository = $userRepository; 30 | 31 | $this->apiConsumer = $app->make('apiconsumer'); 32 | $this->auth = $app->make('auth'); 33 | $this->cookie = $app->make('cookie'); 34 | $this->db = $app->make('db'); 35 | $this->request = $app->make('request'); 36 | } 37 | 38 | /** 39 | * Attempt to create an access token using user credentials. 40 | * 41 | * @param string $email 42 | * @param string $password 43 | */ 44 | public function attemptLogin($email, $password) 45 | { 46 | $user = $this->userRepository->getWhere('email', $email)->first(); 47 | 48 | if (is_null($user)) { 49 | throw new InvalidCredentialsException(); 50 | } 51 | 52 | if (!Hash::check($password, $user->password)) { 53 | throw new InvalidCredentialsException(); 54 | } 55 | 56 | return $this->proxy('password', [ 57 | 'id' => $user->id, 58 | 'first_name' => $user->first_name, 59 | 'last_name' => $user->last_name, 60 | 'username' => $email, 61 | 'password' => $password 62 | ]); 63 | } 64 | 65 | /** 66 | * Attempt to refresh the access token used a refresh token that 67 | * has been saved in a cookie. 68 | */ 69 | public function attemptRefresh() 70 | { 71 | $refreshToken = $this->request->cookie(self::REFRESH_TOKEN); 72 | 73 | return $this->proxy('refresh_token', [ 74 | 'refresh_token' => $refreshToken 75 | ]); 76 | } 77 | 78 | /** 79 | * Proxy a request to the OAuth server. 80 | * 81 | * @param string $grantType what type of grant type should be proxied. 82 | * @param array $datas the data to send to the server. 83 | */ 84 | public function proxy($grantType, array $datas = []) 85 | { 86 | $data = array_merge($datas, [ 87 | 'client_id' => config('passport.password_client_id'), 88 | 'client_secret' => config('passport.password_client_secret'), 89 | 'grant_type' => $grantType 90 | ]); 91 | 92 | $response = $this->apiConsumer->post('/oauth/token', $data); 93 | 94 | if (!$response->isSuccessful()) { 95 | throw new Exception($response); 96 | } 97 | 98 | $data = json_decode($response->getContent()); 99 | 100 | // Create a refresh token cookie 101 | // The reason why you should save the refresh token as a HttpOnly cookie is to prevent Cross-site scripting (XSS) attacks. 102 | // The HttpOnly flag tells the browser that this cookie should not be accessible through javascript. 103 | $this->cookie->queue( 104 | self::REFRESH_TOKEN, 105 | $data->refresh_token, 106 | 864000, // 10 days 107 | null, 108 | null, 109 | false, 110 | true // HttpOnly 111 | ); 112 | 113 | return [ 114 | 'access_token' => $data->access_token, 115 | 'expires_in' => $data->expires_in, 116 | 'id' => $datas['id'], 117 | 'first_name' => $datas['first_name'], 118 | 'last_name' => $datas['last_name'] 119 | ]; 120 | } 121 | 122 | /** 123 | * Logs out the user. We revoke access token and refresh token. 124 | * Also instruct the client to forget the refresh cookie. 125 | */ 126 | public function logout() 127 | { 128 | $accessToken = $this->auth->user()->token(); 129 | 130 | $refreshToken = $this->db 131 | ->table('oauth_refresh_tokens') 132 | ->where('access_token_id', $accessToken->id) 133 | ->update([ 134 | 'revoked' => true 135 | ]); 136 | 137 | $accessToken->revoke(); 138 | 139 | $this->cookie->queue($this->cookie->forget(self::REFRESH_TOKEN)); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /infrastructure/Auth/Services/RegisterService.php: -------------------------------------------------------------------------------- 1 | userRepository = $userRepository; 17 | $this->dispatcher = $dispatcher; 18 | } 19 | 20 | public function store($data) 21 | { 22 | $user = $this->userRepository->create($data); 23 | 24 | $this->dispatcher->dispatch(new Registered($user)); 25 | 26 | $sendData['access_token'] = $user->token() ?? $user->createToken('Random-String-Here')->accessToken; 27 | 28 | $sendData['user'] = $user; 29 | 30 | return $sendData; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /infrastructure/Auth/routes.php: -------------------------------------------------------------------------------- 1 | post('/logout', 'LoginController@logout'); 7 | -------------------------------------------------------------------------------- /infrastructure/Auth/routes_public.php: -------------------------------------------------------------------------------- 1 | post('/login', 'LoginController@login'); 7 | $router->post('/login/refresh', 'LoginController@refresh'); 8 | 9 | // Register 10 | $router->post('/register', 'RegisterController@store'); 11 | -------------------------------------------------------------------------------- /infrastructure/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | // 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /infrastructure/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | generateExceptionResponse(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /infrastructure/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | \Infrastructure\Http\Middlewares\AccessTokenChecker::class, 42 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 43 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 44 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 45 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 46 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 47 | 'logger' => \Infrastructure\Http\Middlewares\Logger::class, 48 | 'role' => Laratrust\Middleware\LaratrustRole::class, 49 | ]; 50 | } 51 | -------------------------------------------------------------------------------- /infrastructure/Http/Middlewares/AccessTokenChecker.php: -------------------------------------------------------------------------------- 1 | authenticate = $authenticate; 18 | } 19 | 20 | public function handle($request, Closure $next, $scopesString = null) 21 | { 22 | try { 23 | return $this->authenticate->handle($request, $next, 'api'); 24 | } catch (AuthenticationException $e) { 25 | throw new UnauthorizedHttpException('Challenge', 'Login to continue.'); 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /infrastructure/Http/Middlewares/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | url(); 32 | $requestMethod = $request->method(); 33 | $logText = "Method: ". $requestMethod. ' - URL: '. $requestUrl. " - Total Queries Executed: $countQueries - Response Time: $responseTime"; 34 | 35 | if ($countQueries) { 36 | if (app()->environment('production')) { 37 | Log::channel('slack')->info([$logText, $queries]); 38 | } else { 39 | ($dump) ? dump([$logText, $queries]) : Log::info([$logText, $queries]); 40 | } 41 | } 42 | 43 | return $response; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /infrastructure/Logging/SlackLogFormatter.php: -------------------------------------------------------------------------------- 1 | getHandlers() as $handler) { 13 | if ($handler instanceof SlackWebhookHandler) { 14 | $handler->setFormatter(new LineFormatter( 15 | '[%datetime%] %channel%.%level_name%: %message% %context% %extra%' 16 | )); 17 | 18 | $handler->pushProcessor([$this, 'processLogRecord']); 19 | } 20 | } 21 | } 22 | 23 | public function processLogRecord(array $record): array 24 | { 25 | if (request()->getPathInfo()) { 26 | $record['extra']['Api URL'] = asset(request()->getPathInfo()); 27 | } 28 | 29 | return $record; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /infrastructure/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 20 | ]; 21 | 22 | /** 23 | * Register any authentication / authorization services. 24 | * 25 | * @return void 26 | */ 27 | public function boot() 28 | { 29 | $this->registerPolicies(); 30 | 31 | Passport::routes(function ($router) { 32 | $router->forAccessTokens(); 33 | // Uncomment for allowing personal access tokens 34 | // $router->forPersonalAccessTokens(); 35 | $router->forTransientTokens(); 36 | }); 37 | 38 | Passport::tokensExpireIn(Carbon::now()->addMinutes(1440)); 39 | 40 | Passport::refreshTokensExpireIn(Carbon::now()->addDays(10)); 41 | 42 | Gate::define('update-user', [UserPolicy::class, 'update']); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /infrastructure/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 22 | 23 | Route::pattern('id', '[0-9]+'); 24 | 25 | parent::boot(); 26 | } 27 | 28 | /** 29 | * Configure the rate limiters for the application. 30 | * 31 | * @return void 32 | */ 33 | protected function configureRateLimiting() 34 | { 35 | RateLimiter::for('api', function (Request $request) { 36 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); 37 | }); 38 | } 39 | 40 | /** 41 | * Define the routes for the application. 42 | * 43 | * @param \Illuminate\Routing\Router $router 44 | * @return void 45 | */ 46 | public function map(Router $router) 47 | { 48 | $extraRoutes = config('larapi.extra_routes'); 49 | 50 | $highLevelParts = array_map(function ($namespace) { 51 | return glob(sprintf('%s%s*', $namespace, DIRECTORY_SEPARATOR), GLOB_ONLYDIR); 52 | }, config('larapi.extra_routes_namespaces')); 53 | 54 | foreach ($highLevelParts as $part => $partComponents) { 55 | foreach ($partComponents as $componentRoot) { 56 | $component = substr($componentRoot, strrpos($componentRoot, DIRECTORY_SEPARATOR) + 1); 57 | 58 | $namespace = sprintf( 59 | '%s\\%s\\Controllers', 60 | $part, 61 | $component 62 | ); 63 | 64 | foreach ($extraRoutes as $routeName => $route) { 65 | $path = sprintf('%s/%s.php', $componentRoot, $routeName); 66 | 67 | if (!file_exists($path)) { 68 | continue; 69 | } 70 | 71 | $namespace = sprintf( 72 | '%s\\%s\\'. $route['namespace'], 73 | $part, 74 | $component 75 | ); 76 | 77 | $router->group([ 78 | 'middleware' => $route['middleware'], 79 | 'namespace' => $namespace, 80 | 'prefix' => $route['prefix'] 81 | ], function ($router) use ($path) { 82 | require $path; 83 | }); 84 | } 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /infrastructure/Testing/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /infrastructure/Testing/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 17 | 18 | $response->assertStatus(200); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /infrastructure/Testing/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./infrastructure/Testing/Unit 10 | 11 | 12 | ./infrastructure/Testing/Feature 13 | 14 | 15 | 16 | 17 | ./api 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gent-fella-health/laravel-api-starter/64b3f5ed5b06d2dff936e3ce739aafaf3b252a4c/pic.png -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteRule ^(.*)/$ /$1 [L,R=301] 11 | 12 | # Handle Front Controller... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_FILENAME} !-f 15 | RewriteRule ^ index.php [L] 16 | 17 | # Handle Authorization Header 18 | RewriteCond %{HTTP:Authorization} . 19 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 20 | 21 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = tap($kernel->handle( 52 | $request = Request::capture() 53 | ))->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | **Laravel API Starter** streamlines modern API development in Laravel. This carefully crafted starter project is designed to simplify and expedite your journey in building APIs with Laravel. Serving as a launchpad for your next project, it equips you with a comprehensive set of ready-to-use tools commonly required in API development. Save time and kickstart your Laravel API project effortlessly with **Laravel API Starter**. 4 | 5 | **Laravel API Starter** comes included with... 6 | 7 | * Laravel Passport for OAuth Authentication, including a proxy for password and refresh-token grants. 8 | * A new directory structure optimized for separating infrastructure and domain code. Groups your controllers, models, etc. by resource-type. 9 | * A modern exception handler for APIs. 10 | * A base controller class that gives sorting, filtering, eager loading and pagination for your endpoints. 11 | * A base repository class for requesting entities from your database. 12 | * A library for creating advanced structures of related entities. 13 | 14 | ![...](pic.png?raw=true "...") 15 | 16 | ## Automatic Installation 17 | 18 | ```bash 19 | git clone https://github.com/gentritabazi/laravel-api-starter && cd laravel-api-starter && sh ./scripts/install.sh 20 | ``` 21 | 22 | This will: 23 | 24 | - Create the project. 25 | - Install the dependencies. 26 | - Create the `.env` file in the project root. 27 | - Generate the `APP_KEY`. 28 | - Create a symbolic link from `public/storage` to `storage/app/public`. 29 | 30 | Now you just need to update your `.env` file as needed and install passport (check below how to install passport). 31 | 32 | ### Manual Installation 33 | 34 | First clone the repository. 35 | 36 | ```bash 37 | git clone https://github.com/gentritabazi/laravel-api-starter 38 | ``` 39 | 40 | Install dependencies. 41 | 42 | ```bash 43 | composer install 44 | ``` 45 | 46 | Copy the `.env` file an create and application key. 47 | 48 | ```bash 49 | cp .env.example .env && php artisan key:generate 50 | ``` 51 | 52 | Create a symbolic link from `public/storage` to `storage/app/public`. 53 | 54 | ```bash 55 | php artisan storage:link 56 | ``` 57 | 58 | Migrate the tables. 59 | 60 | ```bash 61 | php artisan migrate 62 | ``` 63 | 64 | Project comes with Passport include as the default authenticatin method. You should now install it using this command. 65 | 66 | ```bash 67 | php artisan passport:install 68 | ``` 69 | 70 | Copy-paste the generated secrets and IDs into your `.env` file like so. 71 | 72 | ```bash 73 | PERSONAL_CLIENT_ID=1 74 | PERSONAL_CLIENT_SECRET=SECRET_HERE 75 | PASSWORD_CLIENT_ID=2 76 | PASSWORD_CLIENT_SECRET=SECRET_HERE 77 | ``` 78 | 79 | If you want to save it elsewhere or change the naming be sure to modify the LoginService in `infrastructure/Auth/Services/LoginService.php` 80 | 81 | If you want to use docker to install composer dependencies use this [script](https://laravel.com/docs/8.x/sail#installing-composer-dependencies-for-existing-projects). 82 | 83 | ## Test installation 84 | 85 | You can quickly test if the authentication works by creating an user using the include command. 86 | 87 | ```bash 88 | php artisan users:add {first_name} {last_name} {email} {password} 89 | Example: php artisan users:add Gentrit Abazi gentritabazi@gmail.com mypassword 90 | ``` 91 | 92 | Now serve your application and try to request a token using cURL 93 | 94 | ```bash 95 | php artisan serve 96 | curl -X POST http://localhost:8000/login -H 'Content-Type:application/json' -d ' 97 | { 98 | "email": "gentritabazi@gmail.com", 99 | "password": "mypassword" 100 | }' 101 | ``` 102 | 103 | This should return a token. 104 | 105 | ```json 106 | { 107 | "access_token": "TOKEN_HERE", 108 | "expires_in": 600 109 | } 110 | ``` 111 | 112 | Now try to request all users `GET /users` using the newly issued token. 113 | 114 | ```bash 115 | curl http://localhost:8000/users -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImM0MWZiOWFjZjkyZmRiY2RhYjE0ZmEwYTFlMzMwYjBjYTEwMmRiMTA1ZGI4MmZjYzllZGUwMjRiNzI2MjA2YjRhZDU4MGZhMjUxODU2Y2RkIn0.eyJhdWQiOiIyIiwianRpIjoiYzQxZmI5YWNmOTJmZGJjZGFiMTRmYTBhMWUzMzBiMGNhMTAyZGIxMDVkYjgyZmNjOWVkZTAyNGI3MjYyMDZiNGFkNTgwZmEyNTE4NTZjZGQiLCJpYXQiOjE0ODk5NTM3MDYsIm5iZiI6MTQ4OTk1MzcwNiwiZXhwIjoxNDg5OTU0MzA2LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.SmsEyCEXBiwSgl0yMcjvCxoZ2a_7D6GDJTxTs_J-6yzUeJkOofrSV7RRafO3VvUckrNqy5sGgglrwGH_HN7_lNPU6XcgaaNzbzf-g7vCSzCicJiYZVzxqJpZVwqQ4WIQrc0lYdk7suZ7hwQulOD_Z79JhBNh1KSAyo3ABWHiRjh9NR_-iAjvlCohh7nAETDeVqoMrR99m3fwQYOjdtvRBHJ8Ei-Kx3Gn1DyOXyh8eGa5-yDtj-ZVI9x66YMXlm8wk4IMA_Oh7KJISfdpoQs4fPyrGsFAxQMFp02qEW2fzKl2eesZeiIAyDGWE4StHsuY3E4jZL0P-pjv08j5W4CBP0P64gkNw_GdbxlPPA-qZUzJlc3EtjrzZ9WZq3JAKKCGy5I1jHECDOqaQ1z7axm6rmxRWmXmRGwwkne8QxfPlXsN0sm5q98mJckeqCLUuir1VPyFn5Z-B7D80-sc7Zm-7zi-awJtZUGMcHSo_yNHXjVGcbJwFk04xoIL2QzMXpOVPLaUdlBp_obCJhdzT5Bx0o5SDdK2LwgEwbMkksqmrTJ7ypoezsc3ihVQIrMelK2lNfkH_cDcVdD3ub8oFTthbA62U6atXaIADcsgTCgOtgQ2uXTIko_btjECgL35LZDd8UxiyQT3w-pDrELGDPx17DQCsIZDJ8mC1s6E0d7EPsA' 116 | ``` 117 | 118 | This should return a response like so 119 | 120 | ```json 121 | { 122 | "users": [ 123 | { 124 | "id":1, 125 | "first_name": "Gentrit", 126 | "last_name": "Abazi", 127 | "email": "gentritabazi@gmail.com", 128 | "name": "Gentrit Abazi" 129 | } 130 | ] 131 | } 132 | ``` 133 | 134 | You can refresh a new token by requesting `POST /login/refresh` and logout using `POST /logout`. 135 | 136 | ## Directory structure example 137 | 138 | - [Laravel 7.0](https://github.com/gentritabazi/laravel-api-starter/tree/Laravel-7) 139 | - [Laravel 8.0](https://github.com/gentritabazi/laravel-api-starter/tree/Laravel-8). 140 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_equals' => 'The :attribute must be a date equal to :date.', 36 | 'date_format' => 'The :attribute does not match the format :format.', 37 | 'different' => 'The :attribute and :other must be different.', 38 | 'digits' => 'The :attribute must be :digits digits.', 39 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 40 | 'dimensions' => 'The :attribute has invalid image dimensions.', 41 | 'distinct' => 'The :attribute field has a duplicate value.', 42 | 'email' => 'The :attribute must be a valid email address.', 43 | 'ends_with' => 'The :attribute must end with one of the following: :values', 44 | 'exists' => 'The selected :attribute is invalid.', 45 | 'file' => 'The :attribute must be a file.', 46 | 'filled' => 'The :attribute field must have a value.', 47 | 'gt' => [ 48 | 'numeric' => 'The :attribute must be greater than :value.', 49 | 'file' => 'The :attribute must be greater than :value kilobytes.', 50 | 'string' => 'The :attribute must be greater than :value characters.', 51 | 'array' => 'The :attribute must have more than :value items.', 52 | ], 53 | 'gte' => [ 54 | 'numeric' => 'The :attribute must be greater than or equal :value.', 55 | 'file' => 'The :attribute must be greater than or equal :value kilobytes.', 56 | 'string' => 'The :attribute must be greater than or equal :value characters.', 57 | 'array' => 'The :attribute must have :value items or more.', 58 | ], 59 | 'image' => 'The :attribute must be an image.', 60 | 'in' => 'The selected :attribute is invalid.', 61 | 'in_array' => 'The :attribute field does not exist in :other.', 62 | 'integer' => 'The :attribute must be an integer.', 63 | 'ip' => 'The :attribute must be a valid IP address.', 64 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 65 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 66 | 'json' => 'The :attribute must be a valid JSON string.', 67 | 'lt' => [ 68 | 'numeric' => 'The :attribute must be less than :value.', 69 | 'file' => 'The :attribute must be less than :value kilobytes.', 70 | 'string' => 'The :attribute must be less than :value characters.', 71 | 'array' => 'The :attribute must have less than :value items.', 72 | ], 73 | 'lte' => [ 74 | 'numeric' => 'The :attribute must be less than or equal :value.', 75 | 'file' => 'The :attribute must be less than or equal :value kilobytes.', 76 | 'string' => 'The :attribute must be less than or equal :value characters.', 77 | 'array' => 'The :attribute must not have more than :value items.', 78 | ], 79 | 'max' => [ 80 | 'numeric' => 'The :attribute may not be greater than :max.', 81 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 82 | 'string' => 'The :attribute may not be greater than :max characters.', 83 | 'array' => 'The :attribute may not have more than :max items.', 84 | ], 85 | 'mimes' => 'The :attribute must be a file of type: :values.', 86 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 87 | 'min' => [ 88 | 'numeric' => 'The :attribute must be at least :min.', 89 | 'file' => 'The :attribute must be at least :min kilobytes.', 90 | 'string' => 'The :attribute must be at least :min characters.', 91 | 'array' => 'The :attribute must have at least :min items.', 92 | ], 93 | 'not_in' => 'The selected :attribute is invalid.', 94 | 'not_regex' => 'The :attribute format is invalid.', 95 | 'numeric' => 'The :attribute must be a number.', 96 | 'present' => 'The :attribute field must be present.', 97 | 'regex' => 'The :attribute format is invalid.', 98 | 'required' => 'The :attribute field is required.', 99 | 'required_if' => 'The :attribute field is required when :other is :value.', 100 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 101 | 'required_with' => 'The :attribute field is required when :values is present.', 102 | 'required_with_all' => 'The :attribute field is required when :values are present.', 103 | 'required_without' => 'The :attribute field is required when :values is not present.', 104 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 105 | 'same' => 'The :attribute and :other must match.', 106 | 'size' => [ 107 | 'numeric' => 'The :attribute must be :size.', 108 | 'file' => 'The :attribute must be :size kilobytes.', 109 | 'string' => 'The :attribute must be :size characters.', 110 | 'array' => 'The :attribute must contain :size items.', 111 | ], 112 | 'starts_with' => 'The :attribute must start with one of the following: :values', 113 | 'string' => 'The :attribute must be a string.', 114 | 'timezone' => 'The :attribute must be a valid zone.', 115 | 'unique' => 'The :attribute has already been taken.', 116 | 'uploaded' => 'The :attribute failed to upload.', 117 | 'url' => 'The :attribute format is invalid.', 118 | 'uuid' => 'The :attribute must be a valid UUID.', 119 | 120 | /* 121 | |-------------------------------------------------------------------------- 122 | | Custom Validation Language Lines 123 | |-------------------------------------------------------------------------- 124 | | 125 | | Here you may specify custom validation messages for attributes using the 126 | | convention "attribute.rule" to name the lines. This makes it quick to 127 | | specify a specific custom language line for a given attribute rule. 128 | | 129 | */ 130 | 131 | 'custom' => [ 132 | 'attribute-name' => [ 133 | 'rule-name' => 'custom-message', 134 | ], 135 | ], 136 | 137 | /* 138 | |-------------------------------------------------------------------------- 139 | | Custom Validation Attributes 140 | |-------------------------------------------------------------------------- 141 | | 142 | | The following language lines are used to swap our attribute placeholder 143 | | with something more reader friendly such as "E-Mail Address" instead 144 | | of "email". This simply helps us make our message more expressive. 145 | | 146 | */ 147 | 148 | 'attributes' => [], 149 | 150 | ]; 151 | -------------------------------------------------------------------------------- /resources/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gent-fella-health/laravel-api-starter/64b3f5ed5b06d2dff936e3ce739aafaf3b252a4c/resources/views/.gitkeep -------------------------------------------------------------------------------- /scripts/install-with-docker.sh: -------------------------------------------------------------------------------- 1 | echo "Installing Project..." 2 | 3 | docker run --rm \ 4 | -v $(pwd):/opt \ 5 | -w /opt \ 6 | laravelsail/php80-composer:latest \ 7 | composer install 8 | cp .env.example .env 9 | ./vendor/bin/sail up -d && ./vendor/bin/sail artisan key:generate && ./vendor/bin/sail artisan storage:link 10 | 11 | echo "Project Installed!" 12 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | echo "Installing Project..." 2 | 3 | composer install 4 | cp .env.example .env 5 | php artisan key:generate 6 | php artisan storage:link 7 | 8 | echo "Project Installed!" 9 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | --------------------------------------------------------------------------------