├── .editorconfig ├── .env.example ├── .env.testing ├── .gitattributes ├── .github └── workflows │ ├── main.yml │ └── main_laravel8.yml ├── .gitignore ├── .styleci.yml ├── README.md ├── app ├── Actions │ ├── Fortify │ │ ├── CreateNewUser.php │ │ ├── PasswordValidationRules.php │ │ ├── ResetUserPassword.php │ │ ├── UpdateUserPassword.php │ │ └── UpdateUserProfileInformation.php │ └── Jetstream │ │ └── DeleteUser.php ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Controller.php │ │ ├── RoleController.php │ │ ├── SessionController.php │ │ └── UserController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── AuthGates.php │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php │ └── Requests │ │ ├── StoreUserRequest.php │ │ ├── UpdateSessionRequest.php │ │ └── UpdateUserRequest.php ├── Models │ ├── Permission.php │ ├── Role.php │ ├── Session.php │ └── User.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── FortifyServiceProvider.php │ ├── JetstreamServiceProvider.php │ └── RouteServiceProvider.php └── View │ └── Components │ ├── AppLayout.php │ └── GuestLayout.php ├── artisan ├── azure-deploy-php8.sh ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filesystems.php ├── fortify.php ├── hashing.php ├── jetstream.php ├── logging.php ├── mail.php ├── queue.php ├── sanctum.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 │ ├── 2014_10_12_200000_add_two_factor_columns_to_users_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2022_01_16_021708_create_sessions_table.php │ ├── 2022_01_16_183515_create_roles_table.php │ ├── 2022_01_16_183824_create_permissions_table.php │ ├── 2022_01_16_183920_create_permission_role_pivot_table.php │ └── 2022_01_16_184008_create_role_user_pivot_table.php └── seeders │ ├── DatabaseSeeder.php │ ├── PermissionRoleTableSeeder.php │ ├── PermissionsTableSeeder.php │ ├── RoleUserTableSeeder.php │ ├── RolesTableSeeder.php │ └── UsersTableSeeder.php ├── docker-compose.yml ├── nginx.conf ├── package-lock.json ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── css │ └── app.css ├── favicon.ico ├── index.php ├── js │ └── app.js ├── mix-manifest.json └── robots.txt ├── resources ├── css │ └── app.css ├── js │ ├── app.js │ └── bootstrap.js ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php ├── markdown │ ├── policy.md │ └── terms.md └── views │ ├── admin │ ├── sessions │ │ └── index.blade.php │ └── users │ │ ├── create.blade.php │ │ ├── edit.blade.php │ │ ├── index.blade.php │ │ ├── show.blade.php │ │ └── table.blade.php │ ├── api │ ├── api-token-manager.blade.php │ └── index.blade.php │ ├── auth │ ├── confirm-password.blade.php │ ├── forgot-password.blade.php │ ├── login.blade.php │ ├── register.blade.php │ ├── reset-password.blade.php │ ├── two-factor-challenge.blade.php │ └── verify-email.blade.php │ ├── dashboard.blade.php │ ├── layouts │ ├── app.blade.php │ └── guest.blade.php │ ├── navigation-menu.blade.php │ ├── policy.blade.php │ ├── profile │ ├── delete-user-form.blade.php │ ├── logout-other-browser-sessions-form.blade.php │ ├── show.blade.php │ ├── two-factor-authentication-form.blade.php │ ├── update-password-form.blade.php │ └── update-profile-information-form.blade.php │ ├── terms.blade.php │ ├── vendor │ └── jetstream │ │ ├── components │ │ ├── action-message.blade.php │ │ ├── action-section.blade.php │ │ ├── application-logo.blade.php │ │ ├── application-mark.blade.php │ │ ├── authentication-card-logo.blade.php │ │ ├── authentication-card.blade.php │ │ ├── banner.blade.php │ │ ├── button.blade.php │ │ ├── checkbox.blade.php │ │ ├── confirmation-modal.blade.php │ │ ├── confirms-password.blade.php │ │ ├── danger-button.blade.php │ │ ├── dialog-modal.blade.php │ │ ├── dropdown-link.blade.php │ │ ├── dropdown.blade.php │ │ ├── form-section.blade.php │ │ ├── input-error.blade.php │ │ ├── input.blade.php │ │ ├── label.blade.php │ │ ├── modal.blade.php │ │ ├── nav-link.blade.php │ │ ├── responsive-nav-link.blade.php │ │ ├── secondary-button.blade.php │ │ ├── section-border.blade.php │ │ ├── section-title.blade.php │ │ ├── switchable-team.blade.php │ │ ├── validation-errors.blade.php │ │ └── welcome.blade.php │ │ └── mail │ │ └── team-invitation.blade.php │ └── welcome.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tailwind.config.js ├── tests ├── CreatesApplication.php ├── Feature │ ├── ApiTokenPermissionsTest.php │ ├── AuthenticationTest.php │ ├── BrowserSessionsTest.php │ ├── CreateApiTokenTest.php │ ├── DeleteAccountTest.php │ ├── DeleteApiTokenTest.php │ ├── EmailVerificationTest.php │ ├── ExampleTest.php │ ├── PasswordConfirmationTest.php │ ├── PasswordResetTest.php │ ├── ProfileInformationTest.php │ ├── RegistrationTest.php │ ├── TwoFactorAuthenticationSettingsTest.php │ └── UpdatePasswordTest.php ├── TestCase.php └── Unit │ ├── ExampleTest.php │ └── UserTest.php └── webpack.mix.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=sqlite 12 | #DB_HOST=mysql 13 | #DB_PORT=3306 14 | #DB_DATABASE=..\database\database.sqlite 15 | #DB_USERNAME=sail 16 | #DB_PASSWORD=password 17 | DB_TIMEZONE=-03:00 18 | 19 | BROADCAST_DRIVER=log 20 | CACHE_DRIVER=file 21 | FILESYSTEM_DRIVER=local 22 | QUEUE_CONNECTION=sync 23 | SESSION_DRIVER=database 24 | 25 | #3dias=259200seg 26 | SESSION_LIFETIME=259200 27 | #15min=900seg 28 | ACTIVE_SESSIONS_TIME=900 29 | 30 | #MEMCACHED_HOST=127.0.0.1 31 | MEMCACHED_HOST=memcached 32 | 33 | REDIS_HOST=redis 34 | REDIS_PASSWORD=null 35 | REDIS_PORT=6379 36 | 37 | MAIL_MAILER=smtp 38 | MAIL_HOST=mailhog 39 | MAIL_PORT=1025 40 | MAIL_USERNAME=null 41 | MAIL_PASSWORD=null 42 | MAIL_ENCRYPTION=null 43 | MAIL_FROM_ADDRESS=null 44 | MAIL_FROM_NAME="${APP_NAME}" 45 | 46 | AWS_ACCESS_KEY_ID= 47 | AWS_SECRET_ACCESS_KEY= 48 | AWS_DEFAULT_REGION=us-east-1 49 | AWS_BUCKET= 50 | AWS_USE_PATH_STYLE_ENDPOINT=false 51 | 52 | PUSHER_APP_ID= 53 | PUSHER_APP_KEY= 54 | PUSHER_APP_SECRET= 55 | PUSHER_APP_CLUSTER=mt1 56 | 57 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 58 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 59 | 60 | SCOUT_DRIVER=meilisearch 61 | MEILISEARCH_HOST=http://meilisearch:7700 -------------------------------------------------------------------------------- /.env.testing: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=testing 3 | APP_KEY=base64:CyQSuhxpRzZZzx/jdvk69IQMuQ36y+YSBbe5NytnC9g= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=sqlite_test 12 | #DB_HOST=mysql 13 | #DB_PORT=3306 14 | # DB_DATABASE=..\database\test.sqlite 15 | #DB_USERNAME=sail 16 | #DB_PASSWORD=password 17 | DB_TIMEZONE=-03:00 18 | 19 | BROADCAST_DRIVER=log 20 | CACHE_DRIVER=array 21 | FILESYSTEM_DRIVER=local 22 | QUEUE_CONNECTION=sync 23 | QUEUE_DRIVER=sync 24 | MAIL_DRIVER=array 25 | SESSION_DRIVER=array 26 | SESSION_STORE=memcached 27 | SESSION_LIFETIME=120 28 | #15min=900seg 29 | ACTIVE_SESSIONS_TIME=900 30 | 31 | MEMCACHED_HOST=memcached 32 | 33 | REDIS_HOST=redis 34 | REDIS_PASSWORD=null 35 | REDIS_PORT=6379 36 | 37 | MAIL_MAILER=smtp 38 | MAIL_HOST=mailhog 39 | MAIL_PORT=1025 40 | MAIL_USERNAME=null 41 | MAIL_PASSWORD=null 42 | MAIL_ENCRYPTION=null 43 | MAIL_FROM_ADDRESS=null 44 | MAIL_FROM_NAME="${APP_NAME}" 45 | 46 | AWS_ACCESS_KEY_ID= 47 | AWS_SECRET_ACCESS_KEY= 48 | AWS_DEFAULT_REGION=us-east-1 49 | AWS_BUCKET= 50 | AWS_USE_PATH_STYLE_ENDPOINT=false 51 | 52 | PUSHER_APP_ID= 53 | PUSHER_APP_KEY= 54 | PUSHER_APP_SECRET= 55 | PUSHER_APP_CLUSTER=mt1 56 | 57 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 58 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 59 | 60 | SCOUT_DRIVER=meilisearch 61 | MEILISEARCH_HOST=http://meilisearch:7700 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Laravel 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | laravel-tests: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e 16 | with: 17 | php-version: '8.0' 18 | - uses: actions/checkout@v2 19 | - name: Copy .env 20 | run: php -r "file_exists('.env') || copy('.env.example', '.env');" 21 | - name: Install browser-kit-testing 22 | run: composer require laravel/browser-kit-testing --dev 23 | - name: Install Dependencies 24 | run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist 25 | - name: Generate key 26 | run: php artisan key:generate 27 | - name: Directory Permissions 28 | run: chmod -R 777 storage bootstrap/cache 29 | - name: Create Database 30 | run: | 31 | mkdir -p database 32 | touch database/database.sqlite 33 | - name: Execute tests (Unit and Feature tests) via PHPUnit 34 | env: 35 | DB_CONNECTION: sqlite 36 | DB_DATABASE: database/database.sqlite 37 | run: vendor/bin/phpunit 38 | -------------------------------------------------------------------------------- /.github/workflows/main_laravel8.yml: -------------------------------------------------------------------------------- 1 | # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy 2 | # More GitHub Actions for Azure: https://github.com/Azure/actions 3 | 4 | name: Build and deploy PHP app to Azure Web App - Laravel8 5 | 6 | on: 7 | push: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - name: Setup PHP 20 | uses: shivammathur/setup-php@v2 21 | with: 22 | php-version: '8' 23 | 24 | - name: Check if composer.json exists 25 | id: check_files 26 | uses: andstor/file-existence-action@v1 27 | with: 28 | files: 'composer.json' 29 | 30 | - name: Run composer install if composer.json exists 31 | if: steps.check_files.outputs.files_exists == 'true' 32 | run: composer validate --no-check-publish && composer install --prefer-dist --no-progress 33 | 34 | - name: Upload artifact for deployment job 35 | uses: actions/upload-artifact@v2 36 | with: 37 | name: php-app 38 | path: . 39 | 40 | deploy: 41 | runs-on: ubuntu-latest 42 | needs: build 43 | environment: 44 | name: 'Production' 45 | url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} 46 | 47 | steps: 48 | - name: Download artifact from build job 49 | uses: actions/download-artifact@v2 50 | with: 51 | name: php-app 52 | 53 | - name: 'Deploy to Azure Web App' 54 | uses: azure/webapps-deploy@v2 55 | id: deploy-to-webapp 56 | with: 57 | app-name: 'Laravel8' 58 | slot-name: 'Production' 59 | publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_7E83390940CA46439FF74C5F9B1063FB }} 60 | package: . 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | docker-compose.override.yml 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | /.idea 15 | /.vscode 16 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | version: 8 4 | disabled: 5 | - no_unused_imports 6 | finder: 7 | not-name: 8 | - index.php 9 | - server.php 10 | js: 11 | finder: 12 | not-name: 13 | - webpack.mix.js 14 | css: true 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | ## Project: 5 | 6 | Laravel 8 with CRUD: users, favorite movies, products and tags 7 | 8 | ### To Run 9 | 10 | * Requirements: Docker 11 | 12 | #### Using Sail 13 | ```` 14 | git clone https://github.com/estudos-2022/crud-laravel8-app.git appLaravel8 15 | cd appLaravel8 16 | composer install 17 | ./vendor/bin/sail up 18 | cp .env.example .env 19 | ./vendor/bin/sail php artisan key:generate 20 | touch database/database.sqlite 21 | ./vendor/bin/sail php artisan migrate 22 | ./vendor/bin/sail php artisan db:seed 23 | ```` 24 | 25 | #### Using Local Server 26 | ```` 27 | # Clone 28 | git clone https://github.com/estudos-2022/crud-laravel8-app.git appLaravel8 29 | 30 | # Enter in folder 31 | cd appLaravel8 32 | 33 | # Install depedencies 34 | composer install 35 | 36 | # Copy the variable of enviroment, and revise the config 37 | cp .env.example .env 38 | 39 | # Create the key 40 | php artisan key:generate 41 | 42 | # Create the database of Sqlite, except if to use other DB 43 | touch database/database.sqlite 44 | 45 | # Run migration to create the tables of database - to run seed together [php artisan migrate::refresh --seed] 46 | php artisan migrate 47 | 48 | # Run Seed to create some data (roles...) 49 | php artisan db:seed 50 | ```` 51 | 52 | 53 | * About Sail: https://laravel.com/docs/8.x/sail 54 | 55 | After, visit the following address: http://localhost 56 | 57 | To run Unit Test: `./vendor/bin/sail test` or `php artisan test` 58 | 59 | ## License 60 | 61 | This project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 62 | -------------------------------------------------------------------------------- /app/Actions/Fortify/CreateNewUser.php: -------------------------------------------------------------------------------- 1 | ['required', 'string', 'max:255'], 25 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 26 | 'password' => $this->passwordRules(), 27 | 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '', 28 | ])->validate(); 29 | 30 | $user = User::create([ 31 | 'name' => $input['name'], 32 | 'email' => $input['email'], 33 | 'password' => Hash::make($input['password']), 34 | ]); 35 | 36 | $user->roles()->attach(2); 37 | return $user; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Actions/Fortify/PasswordValidationRules.php: -------------------------------------------------------------------------------- 1 | $this->passwordRules(), 24 | ])->validate(); 25 | 26 | $user->forceFill([ 27 | 'password' => Hash::make($input['password']), 28 | ])->save(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Actions/Fortify/UpdateUserPassword.php: -------------------------------------------------------------------------------- 1 | ['required', 'string'], 24 | 'password' => $this->passwordRules(), 25 | ])->after(function ($validator) use ($user, $input) { 26 | if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) { 27 | $validator->errors()->add('current_password', __('The provided password does not match your current password.')); 28 | } 29 | })->validateWithBag('updatePassword'); 30 | 31 | $user->forceFill([ 32 | 'password' => Hash::make($input['password']), 33 | ])->save(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Actions/Fortify/UpdateUserProfileInformation.php: -------------------------------------------------------------------------------- 1 | ['required', 'string', 'max:255'], 23 | 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], 24 | 'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'], 25 | ])->validateWithBag('updateProfileInformation'); 26 | 27 | if (isset($input['photo'])) { 28 | $user->updateProfilePhoto($input['photo']); 29 | } 30 | 31 | if ($input['email'] !== $user->email && 32 | $user instanceof MustVerifyEmail) { 33 | $this->updateVerifiedUser($user, $input); 34 | } else { 35 | $user->forceFill([ 36 | 'name' => $input['name'], 37 | 'email' => $input['email'], 38 | ])->save(); 39 | } 40 | } 41 | 42 | /** 43 | * Update the given verified user's profile information. 44 | * 45 | * @param mixed $user 46 | * @param array $input 47 | * @return void 48 | */ 49 | protected function updateVerifiedUser($user, array $input) 50 | { 51 | $user->forceFill([ 52 | 'name' => $input['name'], 53 | 'email' => $input['email'], 54 | 'email_verified_at' => null, 55 | ])->save(); 56 | 57 | $user->sendEmailVerificationNotification(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/DeleteUser.php: -------------------------------------------------------------------------------- 1 | deleteProfilePhoto(); 18 | $user->tokens->each->delete(); 19 | $user->delete(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 19 | } 20 | 21 | /** 22 | * Register the commands for the application. 23 | * 24 | * @return void 25 | */ 26 | protected function commands() 27 | { 28 | $this->load(__DIR__.'/Commands'); 29 | 30 | require base_path('routes/console.php'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | > 14 | */ 15 | protected $dontReport = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * A list of the inputs that are never flashed for validation exceptions. 21 | * 22 | * @var array 23 | */ 24 | protected $dontFlash = [ 25 | 'current_password', 26 | 'password', 27 | 'password_confirmation', 28 | ]; 29 | 30 | /** 31 | * Register the exception handling callbacks for the application. 32 | * 33 | * @return void 34 | */ 35 | public function register() 36 | { 37 | $this->reportable(function (Throwable $e) { 38 | // 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | $sessions]); 24 | } 25 | 26 | 27 | /** 28 | * Display the specified resource. 29 | * 30 | * @param int $id 31 | * @return \Illuminate\Http\Response 32 | */ 33 | public function show($id) 34 | { 35 | // 36 | } 37 | 38 | public function liveSessions(){ 39 | 40 | $now = time(); 41 | $view_period_default =(15 * 60); // 42 | $time_min = $now-(env("ACTIVE_SESSIONS_TIME", $view_period_default)); 43 | 44 | $totalActiveUsers = Session::where('last_activity','>=', $time_min) 45 | ->groupBy("user_id") 46 | ->get(); 47 | 48 | return $totalActiveUsers; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /app/Http/Controllers/UserController.php: -------------------------------------------------------------------------------- 1 | get(); 25 | // $users = User::all(); 26 | return view('admin.users.index', ['users' => $users]); 27 | } 28 | 29 | public function create() 30 | { 31 | 32 | abort_if(Gate::denies('user_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); 33 | 34 | $roles = Role::pluck('title', 'id'); 35 | 36 | return view('admin.users.create', compact('roles')); 37 | } 38 | 39 | public function store(StoreUserRequest $request) 40 | { 41 | 42 | $user = User::create($request->validated()); 43 | $user->roles()->sync($request->input('roles', [])); 44 | 45 | return redirect()->route('users.index'); 46 | } 47 | 48 | public function show(User $user) 49 | { 50 | abort_if(Gate::denies('user_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); 51 | 52 | return view('admin.users.show', compact('user')); 53 | } 54 | 55 | public function edit(User $user) 56 | { 57 | abort_if(Gate::denies('user_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); 58 | 59 | $roles = Role::pluck('title', 'id'); 60 | 61 | $user->load('roles'); 62 | return view('admin.users.edit', compact('user', 'roles')); 63 | } 64 | 65 | public function update(UpdateUserRequest $request, User $user) 66 | { 67 | $user->update($request->validated()); 68 | $user->roles()->sync($request->input('roles', [])); 69 | 70 | return redirect()->route('users.index'); 71 | } 72 | 73 | public function destroy(User $user) 74 | { 75 | abort_if(Gate::denies('user_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); 76 | 77 | $user->delete(); 78 | 79 | return redirect()->route('users.index'); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Fruitcake\Cors\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class, 37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 38 | \App\Http\Middleware\VerifyCsrfToken::class, 39 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 40 | \App\Http\Middleware\AuthGates::class, 41 | ], 42 | 43 | 'api' => [ 44 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 45 | 'throttle:api', 46 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 47 | \App\Http\Middleware\AuthGates::class, 48 | ], 49 | ]; 50 | 51 | /** 52 | * The application's route middleware. 53 | * 54 | * These middleware may be assigned to groups or used individually. 55 | * 56 | * @var array 57 | */ 58 | protected $routeMiddleware = [ 59 | 'auth' => \App\Http\Middleware\Authenticate::class, 60 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 61 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 62 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 63 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 64 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 65 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 66 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 67 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 68 | ]; 69 | } 70 | -------------------------------------------------------------------------------- /app/Http/Middleware/AuthGates.php: -------------------------------------------------------------------------------- 1 | get(); 17 | $permissionsArray = []; 18 | 19 | foreach ($roles as $role) { 20 | foreach ($role->permissions as $permissions) { 21 | $permissionsArray[$permissions->title][] = $role->id; 22 | } 23 | } 24 | 25 | foreach ($permissionsArray as $title => $roles) { 26 | Gate::define($title, function ($user) use ($roles) { 27 | return count(array_intersect($user->roles->pluck('id')->toArray(), $roles)) > 0; 28 | }); 29 | } 30 | } 31 | 32 | return $next($request); 33 | } 34 | } -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 26 | return redirect(RouteServiceProvider::HOME); 27 | } 28 | } 29 | 30 | return $next($request); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts() 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Requests/StoreUserRequest.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'string', 18 | 'required', 19 | ], 20 | 'email' => [ 21 | 'required', 22 | 'unique:users,email,', // . request()->route('user')->id 23 | ], 24 | 'roles.*' => [ 25 | 'integer', 26 | ], 27 | 'roles' => [ 28 | 'required', 29 | 'array', 30 | ], 31 | ]; 32 | } 33 | 34 | /** 35 | * Determine if the user is authorized to make this request. 36 | * 37 | * @return bool 38 | */ 39 | public function authorize() 40 | { 41 | return Gate::allows('user_access'); 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/Http/Requests/UpdateSessionRequest.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'string', 18 | 'required', 19 | ], 20 | 'email' => [ 21 | 'required', 22 | 'unique:users,email,' . request()->route('user')->id, 23 | ], 24 | 'roles.*' => [ 25 | 'integer', 26 | ], 27 | 'roles' => [ 28 | 'required', 29 | 'array', 30 | ], 31 | ]; 32 | } 33 | 34 | /** 35 | * Determine if the user is authorized to make this request. 36 | * 37 | * @return bool 38 | */ 39 | public function authorize() 40 | { 41 | return Gate::allows('session_access'); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /app/Http/Requests/UpdateUserRequest.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'string', 18 | 'required', 19 | ], 20 | 'email' => [ 21 | 'required', 22 | 'unique:users,email,' . request()->route('user')->id, 23 | ], 24 | 'roles.*' => [ 25 | 'integer', 26 | ], 27 | 'roles' => [ 28 | 'required', 29 | 'array', 30 | ], 31 | ]; 32 | } 33 | 34 | /** 35 | * Determine if the user is authorized to make this request. 36 | * 37 | * @return bool 38 | */ 39 | public function authorize() 40 | { 41 | return Gate::allows('user_access'); 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/Models/Permission.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Role::class); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Models/Role.php: -------------------------------------------------------------------------------- 1 | belongsToMany(User::class); 23 | } 24 | 25 | /** 26 | * Relantionships 27 | * Many to Many 28 | */ 29 | public function permissions() 30 | { 31 | return $this->belongsToMany(Permission::class); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/Models/Session.php: -------------------------------------------------------------------------------- 1 | last_activity); //convert 30 | $timeBD->setTimezone('America/Sao_Paulo'); //change to timezone 31 | return $timeBD->format( 'd-m-Y H:i:s' ); //format 32 | } 33 | 34 | 35 | /** 36 | * Relantionships 37 | * Many to Many 38 | */ 39 | public function users() 40 | { 41 | return $this->belongsTo(User::class, 'user_id'); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 51 | ]; 52 | 53 | /** 54 | * The accessors to append to the model's array form. 55 | * 56 | * @var array 57 | */ 58 | protected $appends = [ 59 | 'profile_photo_url', 60 | ]; 61 | 62 | /** 63 | * Relantionships 64 | * Many to Many 65 | */ 66 | public function roles() 67 | { 68 | return $this->belongsToMany(Role::class); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 'App\Models\Model' => 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/FortifyServiceProvider.php: -------------------------------------------------------------------------------- 1 | email; 41 | 42 | return Limit::perMinute(5)->by($email.$request->ip()); 43 | }); 44 | 45 | RateLimiter::for('two-factor', function (Request $request) { 46 | return Limit::perMinute(5)->by($request->session()->get('login.id')); 47 | }); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/Providers/JetstreamServiceProvider.php: -------------------------------------------------------------------------------- 1 | configurePermissions(); 29 | 30 | Jetstream::deleteUsersUsing(DeleteUser::class); 31 | } 32 | 33 | /** 34 | * Configure the permissions that are available within the application. 35 | * 36 | * @return void 37 | */ 38 | protected function configurePermissions() 39 | { 40 | Jetstream::defaultApiTokenPermissions(['read']); 41 | 42 | Jetstream::permissions([ 43 | 'create', 44 | 'read', 45 | 'update', 46 | 'delete', 47 | ]); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 39 | 40 | $this->routes(function () { 41 | Route::prefix('api') 42 | ->middleware('api') 43 | ->namespace($this->namespace) 44 | ->group(base_path('routes/api.php')); 45 | 46 | Route::middleware('web') 47 | ->namespace($this->namespace) 48 | ->group(base_path('routes/web.php')); 49 | }); 50 | } 51 | 52 | /** 53 | * Configure the rate limiters for the application. 54 | * 55 | * @return void 56 | */ 57 | protected function configureRateLimiting() 58 | { 59 | RateLimiter::for('api', function (Request $request) { 60 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/View/Components/AppLayout.php: -------------------------------------------------------------------------------- 1 | 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 | -------------------------------------------------------------------------------- /azure-deploy-php8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Replacing nginx configuration for serving PHP 8.0-based applications" 3 | cp /home/site/repository/deployment/azure-app-service/nginx.conf /etc/nginx/sites-available/default 4 | 5 | echo "Reloading nginx to apply new configuration" 6 | service nginx reload 7 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^7.3|^8.0", 12 | "fruitcake/laravel-cors": "^2.0", 13 | "guzzlehttp/guzzle": "^7.0.1", 14 | "laravel/framework": "^8.75", 15 | "laravel/jetstream": "^2.6", 16 | "laravel/sanctum": "^2.11", 17 | "laravel/tinker": "^2.5", 18 | "livewire/livewire": "^2.5" 19 | }, 20 | "require-dev": { 21 | "facade/ignition": "^2.5", 22 | "fakerphp/faker": "^1.9.1", 23 | "laravel/browser-kit-testing": "^6.3", 24 | "laravel/sail": "^1.0.1", 25 | "mockery/mockery": "^1.4.4", 26 | "nunomaduro/collision": "^5.10", 27 | "phpunit/phpunit": "^9.5.10" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "App\\": "app/", 32 | "Database\\Factories\\": "database/factories/", 33 | "Database\\Seeders\\": "database/seeders/" 34 | } 35 | }, 36 | "autoload-dev": { 37 | "psr-4": { 38 | "Tests\\": "tests/" 39 | } 40 | }, 41 | "scripts": { 42 | "post-autoload-dump": [ 43 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 44 | "@php artisan package:discover --ansi" 45 | ], 46 | "post-update-cmd": [ 47 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 48 | ], 49 | "post-root-package-install": [ 50 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 51 | ], 52 | "post-create-project-cmd": [ 53 | "@php artisan key:generate --ansi" 54 | ], 55 | "tests": [ 56 | "DB_CONNECTION=sqlite && DB_DATABASE=:memory: && APP_ENV=testing && phpunit --colors=always --no-coverage" 57 | ] 58 | }, 59 | "extra": { 60 | "laravel": { 61 | "dont-discover": [] 62 | } 63 | }, 64 | "config": { 65 | "optimize-autoloader": true, 66 | "preferred-install": "dist", 67 | "sort-packages": true 68 | }, 69 | "minimum-stability": "dev", 70 | "prefer-stable": true 71 | } 72 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'ably' => [ 45 | 'driver' => 'ably', 46 | 'key' => env('ABLY_KEY'), 47 | ], 48 | 49 | 'redis' => [ 50 | 'driver' => 'redis', 51 | 'connection' => 'default', 52 | ], 53 | 54 | 'log' => [ 55 | 'driver' => 'log', 56 | ], 57 | 58 | 'null' => [ 59 | 'driver' => 'null', 60 | ], 61 | 62 | ], 63 | 64 | ]; 65 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", 30 | | "memcached", "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | 'lock_connection' => null, 50 | ], 51 | 52 | 'file' => [ 53 | 'driver' => 'file', 54 | 'path' => storage_path('framework/cache/data'), 55 | ], 56 | 57 | 'memcached' => [ 58 | 'driver' => 'memcached', 59 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 60 | 'sasl' => [ 61 | env('MEMCACHED_USERNAME'), 62 | env('MEMCACHED_PASSWORD'), 63 | ], 64 | 'options' => [ 65 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 66 | ], 67 | 'servers' => [ 68 | [ 69 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 70 | 'port' => env('MEMCACHED_PORT', 11211), 71 | 'weight' => 100, 72 | ], 73 | ], 74 | ], 75 | 76 | 'redis' => [ 77 | 'driver' => 'redis', 78 | 'connection' => 'cache', 79 | 'lock_connection' => 'default', 80 | ], 81 | 82 | 'dynamodb' => [ 83 | 'driver' => 'dynamodb', 84 | 'key' => env('AWS_ACCESS_KEY_ID'), 85 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 86 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 87 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 88 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 89 | ], 90 | 91 | 'octane' => [ 92 | 'driver' => 'octane', 93 | ], 94 | 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Cache Key Prefix 100 | |-------------------------------------------------------------------------- 101 | | 102 | | When utilizing a RAM based store such as APC or Memcached, there might 103 | | be other applications utilizing the same cache. So, we'll specify a 104 | | value to get prefixed to all our keys so we can avoid collisions. 105 | | 106 | */ 107 | 108 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been setup for each driver as an example of the required options. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | ], 37 | 38 | 'public' => [ 39 | 'driver' => 'local', 40 | 'root' => storage_path('app/public'), 41 | 'url' => env('APP_URL').'/storage', 42 | 'visibility' => 'public', 43 | ], 44 | 45 | 's3' => [ 46 | 'driver' => 's3', 47 | 'key' => env('AWS_ACCESS_KEY_ID'), 48 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 49 | 'region' => env('AWS_DEFAULT_REGION'), 50 | 'bucket' => env('AWS_BUCKET'), 51 | 'url' => env('AWS_URL'), 52 | 'endpoint' => env('AWS_ENDPOINT'), 53 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 54 | ], 55 | 56 | ], 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Symbolic Links 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Here you may configure the symbolic links that will be created when the 64 | | `storage:link` Artisan command is executed. The array keys should be 65 | | the locations of the links and the values should be their targets. 66 | | 67 | */ 68 | 69 | 'links' => [ 70 | public_path('storage') => storage_path('app/public'), 71 | ], 72 | 73 | ]; 74 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/jetstream.php: -------------------------------------------------------------------------------- 1 | 'livewire', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Jetstream Route Middleware 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify which middleware Jetstream will assign to the routes 26 | | that it registers with the application. When necessary, you may modify 27 | | these middleware; however, this default value is usually sufficient. 28 | | 29 | */ 30 | 31 | 'middleware' => ['web'], 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Features 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Some of Jetstream's features are optional. You may disable the features 39 | | by removing them from this array. You're free to only remove some of 40 | | these features or you can even remove all of these if you need to. 41 | | 42 | */ 43 | 44 | 'features' => [ 45 | // Features::termsAndPrivacyPolicy(), 46 | // Features::profilePhotos(), 47 | // Features::api(), 48 | // Features::teams(['invitations' => true]), 49 | Features::accountDeletion(), 50 | ], 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Profile Photo Disk 55 | |-------------------------------------------------------------------------- 56 | | 57 | | This configuration value determines the default disk that will be used 58 | | when storing profile photos for your application's users. Typically 59 | | this will be the "public" disk but you may adjust this if needed. 60 | | 61 | */ 62 | 63 | 'profile_photo_disk' => 'public', 64 | 65 | ]; 66 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Deprecations Log Channel 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This option controls the log channel that should be used to log warnings 28 | | regarding deprecated PHP and library features. This allows you to get 29 | | your application ready for upcoming major versions of dependencies. 30 | | 31 | */ 32 | 33 | 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Log Channels 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may configure the log channels for your application. Out of 41 | | the box, Laravel uses the Monolog PHP logging library. This gives 42 | | you a variety of powerful log handlers / formatters to utilize. 43 | | 44 | | Available Drivers: "single", "daily", "slack", "syslog", 45 | | "errorlog", "monolog", 46 | | "custom", "stack" 47 | | 48 | */ 49 | 50 | 'channels' => [ 51 | 'stack' => [ 52 | 'driver' => 'stack', 53 | 'channels' => ['single'], 54 | 'ignore_exceptions' => false, 55 | ], 56 | 57 | 'single' => [ 58 | 'driver' => 'single', 59 | 'path' => storage_path('logs/laravel.log'), 60 | 'level' => env('LOG_LEVEL', 'debug'), 61 | ], 62 | 63 | 'daily' => [ 64 | 'driver' => 'daily', 65 | 'path' => storage_path('logs/laravel.log'), 66 | 'level' => env('LOG_LEVEL', 'debug'), 67 | 'days' => 14, 68 | ], 69 | 70 | 'slack' => [ 71 | 'driver' => 'slack', 72 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 73 | 'username' => 'Laravel Log', 74 | 'emoji' => ':boom:', 75 | 'level' => env('LOG_LEVEL', 'critical'), 76 | ], 77 | 78 | 'papertrail' => [ 79 | 'driver' => 'monolog', 80 | 'level' => env('LOG_LEVEL', 'debug'), 81 | 'handler' => SyslogUdpHandler::class, 82 | 'handler_with' => [ 83 | 'host' => env('PAPERTRAIL_URL'), 84 | 'port' => env('PAPERTRAIL_PORT'), 85 | ], 86 | ], 87 | 88 | 'stderr' => [ 89 | 'driver' => 'monolog', 90 | 'level' => env('LOG_LEVEL', 'debug'), 91 | 'handler' => StreamHandler::class, 92 | 'formatter' => env('LOG_STDERR_FORMATTER'), 93 | 'with' => [ 94 | 'stream' => 'php://stderr', 95 | ], 96 | ], 97 | 98 | 'syslog' => [ 99 | 'driver' => 'syslog', 100 | 'level' => env('LOG_LEVEL', 'debug'), 101 | ], 102 | 103 | 'errorlog' => [ 104 | 'driver' => 'errorlog', 105 | 'level' => env('LOG_LEVEL', 'debug'), 106 | ], 107 | 108 | 'null' => [ 109 | 'driver' => 'monolog', 110 | 'handler' => NullHandler::class, 111 | ], 112 | 113 | 'emergency' => [ 114 | 'path' => storage_path('logs/laravel.log'), 115 | ], 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /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", "failover" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | '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' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | 74 | 'failover' => [ 75 | 'transport' => 'failover', 76 | 'mailers' => [ 77 | 'smtp', 78 | 'log', 79 | ], 80 | ], 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Global "From" Address 86 | |-------------------------------------------------------------------------- 87 | | 88 | | You may wish for all e-mails sent by your application to be sent from 89 | | the same address. Here, you may specify a name and address that is 90 | | used globally for all e-mails that are sent by your application. 91 | | 92 | */ 93 | 94 | 'from' => [ 95 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 96 | 'name' => env('MAIL_FROM_NAME', 'Example'), 97 | ], 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Markdown Mail Settings 102 | |-------------------------------------------------------------------------- 103 | | 104 | | If you are using Markdown based email rendering, you may configure your 105 | | theme and component paths here, allowing you to customize the design 106 | | of the emails. Or, you may simply stick with the Laravel defaults! 107 | | 108 | */ 109 | 110 | 'markdown' => [ 111 | 'theme' => 'default', 112 | 113 | 'paths' => [ 114 | resource_path('views/vendor/mail'), 115 | ], 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | 'after_commit' => false, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | 'block_for' => 0, 51 | 'after_commit' => false, 52 | ], 53 | 54 | 'sqs' => [ 55 | 'driver' => 'sqs', 56 | 'key' => env('AWS_ACCESS_KEY_ID'), 57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 59 | 'queue' => env('SQS_QUEUE', 'default'), 60 | 'suffix' => env('SQS_SUFFIX'), 61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 62 | 'after_commit' => false, 63 | ], 64 | 65 | 'redis' => [ 66 | 'driver' => 'redis', 67 | 'connection' => 'default', 68 | 'queue' => env('REDIS_QUEUE', 'default'), 69 | 'retry_after' => 90, 70 | 'block_for' => null, 71 | 'after_commit' => false, 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Failed Queue Jobs 79 | |-------------------------------------------------------------------------- 80 | | 81 | | These options configure the behavior of failed queue job logging so you 82 | | can control which database and table are used to store the jobs that 83 | | have failed. You may change them to any database / table you wish. 84 | | 85 | */ 86 | 87 | 'failed' => [ 88 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 89 | 'database' => env('DB_CONNECTION', 'mysql'), 90 | 'table' => 'failed_jobs', 91 | ], 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 17 | '%s%s', 18 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 19 | env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' 20 | ))), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Sanctum Guards 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This array contains the authentication guards that will be checked when 28 | | Sanctum is trying to authenticate a request. If none of these guards 29 | | are able to authenticate the request, Sanctum will use the bearer 30 | | token that's present on an incoming request for authentication. 31 | | 32 | */ 33 | 34 | 'guard' => ['web'], 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Expiration Minutes 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This value controls the number of minutes until an issued token will be 42 | | considered expired. If this value is null, personal access tokens do 43 | | not expire. This won't tweak the lifetime of first-party sessions. 44 | | 45 | */ 46 | 47 | 'expiration' => null, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Sanctum Middleware 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When authenticating your first-party SPA with Sanctum you may need to 55 | | customize some of the middleware Sanctum uses while processing the 56 | | request. You may change the middleware listed below as required. 57 | | 58 | */ 59 | 60 | 'middleware' => [ 61 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 62 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 63 | ], 64 | 65 | ]; 66 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->name(), 29 | 'email' => $this->faker->unique()->safeEmail(), 30 | 'email_verified_at' => now(), 31 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 32 | 'remember_token' => Str::random(10), 33 | ]; 34 | } 35 | 36 | /** 37 | * Indicate that the model's email address should be unverified. 38 | * 39 | * @return \Illuminate\Database\Eloquent\Factories\Factory 40 | */ 41 | public function unverified() 42 | { 43 | return $this->state(function (array $attributes) { 44 | return [ 45 | 'email_verified_at' => null, 46 | ]; 47 | }); 48 | } 49 | 50 | /** 51 | * Indicate that the user should have a personal team. 52 | * 53 | * @return $this 54 | */ 55 | public function withPersonalTeam() 56 | { 57 | if (! Features::hasTeamFeatures()) { 58 | return $this->state([]); 59 | } 60 | 61 | return $this->has( 62 | Team::factory() 63 | ->state(function (array $attributes, User $user) { 64 | return ['name' => $user->name.'\'s Team', 'user_id' => $user->id, 'personal_team' => true]; 65 | }), 66 | 'ownedTeams' 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->foreignId('current_team_id')->nullable(); 24 | $table->string('profile_photo_path', 2048)->nullable(); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('users'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php: -------------------------------------------------------------------------------- 1 | text('two_factor_secret') 18 | ->after('password') 19 | ->nullable(); 20 | 21 | $table->text('two_factor_recovery_codes') 22 | ->after('two_factor_secret') 23 | ->nullable(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::table('users', function (Blueprint $table) { 35 | $table->dropColumn('two_factor_secret', 'two_factor_recovery_codes'); 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('uuid')->unique(); 19 | $table->text('connection'); 20 | $table->text('queue'); 21 | $table->longText('payload'); 22 | $table->longText('exception'); 23 | $table->timestamp('failed_at')->useCurrent(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('failed_jobs'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->morphs('tokenable'); 19 | $table->string('name'); 20 | $table->string('token', 64)->unique(); 21 | $table->text('abilities')->nullable(); 22 | $table->timestamp('last_used_at')->nullable(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('personal_access_tokens'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2022_01_16_021708_create_sessions_table.php: -------------------------------------------------------------------------------- 1 | string('id')->primary(); 18 | $table->foreignId('user_id')->nullable()->index(); 19 | $table->string('ip_address', 45)->nullable(); 20 | $table->text('user_agent')->nullable(); 21 | $table->text('payload'); 22 | $table->integer('last_activity')->index(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('sessions'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2022_01_16_183515_create_roles_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('title')->nullable(); 19 | $table->timestamps(); 20 | 21 | $table->softDeletes(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('roles'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2022_01_16_183824_create_permissions_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('title')->nullable(); 19 | $table->timestamps(); 20 | $table->softDeletes(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('permissions'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2022_01_16_183920_create_permission_role_pivot_table.php: -------------------------------------------------------------------------------- 1 | foreignId('role_id')->references('id')->on('roles')->cascadeOnDelete(); 18 | $table->foreignId('permission_id')->references('id')->on('permissions')->cascadeOnDelete(); 19 | }); 20 | } 21 | 22 | 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('permission_role'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2022_01_16_184008_create_role_user_pivot_table.php: -------------------------------------------------------------------------------- 1 | foreignId('role_id')->references('id')->on('roles')->cascadeOnDelete(); 18 | $table->foreignId('user_id')->references('id')->on('users')->cascadeOnDelete(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::dropIfExists('role_user'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | $this->call([ 18 | PermissionsTableSeeder::class, 19 | RolesTableSeeder::class, 20 | PermissionRoleTableSeeder::class, 21 | UsersTableSeeder::class, 22 | RoleUserTableSeeder::class, 23 | ]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/seeders/PermissionRoleTableSeeder.php: -------------------------------------------------------------------------------- 1 | permissions()->sync($admin_permissions->pluck('id')); 20 | $user_permissions = $admin_permissions->filter(function ($permission) { 21 | return substr($permission->title, 0, 5) != 'user_'; 22 | }); 23 | Role::findOrFail(2)->permissions()->sync($user_permissions); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/seeders/PermissionsTableSeeder.php: -------------------------------------------------------------------------------- 1 | 1, 20 | 'title' => 'user_access', 21 | ], 22 | [ 23 | 'id' => 2, 24 | 'title' => 'session_access', 25 | ], 26 | ]; 27 | 28 | Permission::insert($permissions); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/seeders/RoleUserTableSeeder.php: -------------------------------------------------------------------------------- 1 | roles()->sync(1); 18 | User::findOrFail(2)->roles()->sync(2); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /database/seeders/RolesTableSeeder.php: -------------------------------------------------------------------------------- 1 | 1, 20 | 'title' => 'Admin', 21 | ], 22 | [ 23 | 'id' => 2, 24 | 'title' => 'User', 25 | ], 26 | ]; 27 | 28 | Role::insert($roles); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/seeders/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | 1, 20 | 'name' => 'Admin', 21 | 'email' => 'admin@admin.com', 22 | 'password' => bcrypt('password'), 23 | 'remember_token' => null, 24 | ], 25 | [ 26 | 'id' => 2, 27 | 'name' => 'User', 28 | 'email' => 'user@user.com', 29 | 'password' => bcrypt('password'), 30 | 'remember_token' => null, 31 | ], 32 | ]; 33 | 34 | User::insert($users); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # For more information: https://laravel.com/docs/sail 2 | version: '3' 3 | services: 4 | laravel.test: 5 | build: 6 | context: ./vendor/laravel/sail/runtimes/8.1 7 | dockerfile: Dockerfile 8 | args: 9 | WWWGROUP: '${WWWGROUP}' 10 | image: sail-8.1/app 11 | extra_hosts: 12 | - 'host.docker.internal:host-gateway' 13 | ports: 14 | - '${APP_PORT:-80}:80' 15 | environment: 16 | WWWUSER: '${WWWUSER}' 17 | LARAVEL_SAIL: 1 18 | XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' 19 | XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' 20 | volumes: 21 | - '.:/var/www/html' 22 | networks: 23 | - sail 24 | depends_on: 25 | - meilisearch 26 | - redis 27 | memcached: 28 | image: 'memcached:alpine' 29 | ports: 30 | - '11211:11211' 31 | networks: 32 | - sail 33 | meilisearch: 34 | image: 'getmeili/meilisearch:latest' 35 | platform: linux/x86_64 36 | ports: 37 | - '${FORWARD_MEILISEARCH_PORT:-7700}:7700' 38 | volumes: 39 | - 'sailmeilisearch:/data.ms' 40 | networks: 41 | - sail 42 | healthcheck: 43 | test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"] 44 | retries: 3 45 | timeout: 5s 46 | redis: 47 | image: 'redis:alpine' 48 | ports: 49 | - '${FORWARD_REDIS_PORT:-6379}:6379' 50 | volumes: 51 | - 'sailredis:/data' 52 | networks: 53 | - sail 54 | healthcheck: 55 | test: ["CMD", "redis-cli", "ping"] 56 | retries: 3 57 | timeout: 5s 58 | networks: 59 | sail: 60 | driver: bridge 61 | volumes: 62 | sailmeilisearch: 63 | driver: local 64 | sailredis: 65 | driver: local 66 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | # adjusted nginx.conf to make Laravel 8 apps with PHP 8.0 features runnable on Azure App Service 3 | # @see https://laravel.com/docs/8.x/deployment 4 | listen 8080; 5 | listen [::]:8080; 6 | root /home/site/wwwroot/public; 7 | index index.php; 8 | server_name laravel8.azurewebsites.net 9 | 10 | location / { 11 | try_files $uri $uri/ /index.php?$query_string; 12 | } 13 | 14 | # redirect server error pages to the static page /50x.html 15 | # 16 | error_page 500 502 503 504 /50x.html; 17 | location = /50x.html { 18 | root /html/; 19 | } 20 | 21 | location ~ [^/]\.php(/|$) { 22 | fastcgi_split_path_info ^(.+?\.php)(|/.*)$; 23 | fastcgi_pass 127.0.0.1:9000; 24 | include fastcgi_params; 25 | fastcgi_param HTTP_PROXY ""; 26 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 27 | fastcgi_param PATH_INFO $fastcgi_path_info; 28 | fastcgi_param QUERY_STRING $query_string; 29 | fastcgi_intercept_errors on; 30 | fastcgi_connect_timeout 300; 31 | fastcgi_send_timeout 3600; 32 | fastcgi_read_timeout 3600; 33 | fastcgi_buffer_size 128k; 34 | fastcgi_buffers 4 256k; 35 | fastcgi_busy_buffers_size 256k; 36 | fastcgi_temp_file_write_size 256k; 37 | } 38 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "mix", 6 | "watch": "mix watch", 7 | "watch-poll": "mix watch -- --watch-options-poll=1000", 8 | "hot": "mix watch --hot", 9 | "prod": "npm run production", 10 | "production": "mix --production" 11 | }, 12 | "devDependencies": { 13 | "@tailwindcss/forms": "^0.4.0", 14 | "@tailwindcss/typography": "^0.5.0", 15 | "alpinejs": "^3.0.6", 16 | "axios": "^0.21", 17 | "laravel-mix": "^6.0.6", 18 | "lodash": "^4.17.19", 19 | "postcss": "^8.1.14", 20 | "postcss-import": "^14.0.1", 21 | "tailwindcss": "^3.0.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Phoenix-Genius/crud-laravel8-app/c98caa21389caed139867558416fb3055f1a2b51/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } 5 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss/base'; 2 | @import 'tailwindcss/components'; 3 | @import 'tailwindcss/utilities'; 4 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('./bootstrap'); 2 | 3 | import Alpine from 'alpinejs'; 4 | 5 | window.Alpine = Alpine; 6 | 7 | Alpine.start(); 8 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // forceTLS: true 28 | // }); 29 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'password' => 'The provided password is incorrect.', 18 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/markdown/policy.md: -------------------------------------------------------------------------------- 1 | # Privacy Policy 2 | 3 | Edit this file to define the privacy policy for your application. 4 | -------------------------------------------------------------------------------- /resources/markdown/terms.md: -------------------------------------------------------------------------------- 1 | # Terms of Service 2 | 3 | Edit this file to define the terms of service for your application. 4 | -------------------------------------------------------------------------------- /resources/views/admin/sessions/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | {{ __('Browser Sessions') }} 5 |

6 |
7 | 8 |
9 |
10 | 11 | @if (count($sessions) > 0) 12 |
13 | 14 | @foreach ($sessions as $session) 15 |
16 |
17 | #{{ $session->user_id }} 18 | 19 | @if (empty($session->users->name)) 20 | Conta excluída 21 | @else 22 | ({{ $session->users->name }}) 23 | @endif 24 | 25 | {{ $session->last_login }} 26 |
27 |
28 |
29 |
30 |
31 | {{ $session->ip_address }}, 32 | {{ $session->user_agent }}, 33 |
34 |
35 |
36 |
37 | @endforeach 38 |
39 | @endif 40 |
41 |
42 | 43 | -------------------------------------------------------------------------------- /resources/views/admin/users/create.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | Create User 5 |

6 |
7 | 8 |
9 |
10 |
11 |
12 | @csrf 13 |
14 |
15 | 16 | 18 | @error('name') 19 |

{{ $message }}

20 | @enderror 21 |
22 | 23 |
24 | 25 | 27 | @error('email') 28 |

{{ $message }}

29 | @enderror 30 |
31 | 32 |
33 | 34 | 35 | @error('password') 36 |

{{ $message }}

37 | @enderror 38 |
39 | 40 |
41 | 42 | 47 | @error('roles') 48 |

{{ $message }}

49 | @enderror 50 |
51 | 52 |
53 | 56 |
57 |
58 |
59 |
60 |
61 |
62 |
-------------------------------------------------------------------------------- /resources/views/admin/users/table.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | @foreach ($users as $user) 19 | 20 | 21 | 22 | 23 | 24 | 32 | 33 | @endforeach 34 | 35 | 36 |
NameEmailWhatsCPFAções
{{ $user->name }}{{ $user->email }}Whats61930303323 25 | 26 | {{ __('Edit') }} 27 | 28 | 29 | {{ __('View') }} 30 | 31 |
37 | 38 |
39 | 40 | 41 |
42 | 43 | -------------------------------------------------------------------------------- /resources/views/api/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | {{ __('API Tokens') }} 5 |

6 |
7 | 8 |
9 |
10 | @livewire('api.api-token-manager') 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /resources/views/auth/confirm-password.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | {{ __('This is a secure area of the application. Please confirm your password before continuing.') }} 9 |
10 | 11 | 12 | 13 |
14 | @csrf 15 | 16 |
17 | 18 | 19 |
20 | 21 |
22 | 23 | {{ __('Confirm') }} 24 | 25 |
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /resources/views/auth/forgot-password.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | {{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }} 9 |
10 | 11 | @if (session('status')) 12 |
13 | {{ session('status') }} 14 |
15 | @endif 16 | 17 | 18 | 19 |
20 | @csrf 21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 | {{ __('Email Password Reset Link') }} 30 | 31 |
32 |
33 |
34 |
35 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | @if (session('status')) 10 |
11 | {{ session('status') }} 12 |
13 | @endif 14 | 15 |
16 | @csrf 17 | 18 |
19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 |
27 | 28 |
29 | 33 |
34 | 35 |
36 | @if (Route::has('password.request')) 37 | 38 | {{ __('Forgot your password?') }} 39 | 40 | @endif 41 | 42 | 43 | {{ __('Log in') }} 44 | 45 |
46 |
47 |
48 |
49 | -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | @csrf 11 | 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 29 | 30 |
31 | 32 | @if (Laravel\Jetstream\Jetstream::hasTermsAndPrivacyPolicyFeature()) 33 |
34 | 35 |
36 | 37 | 38 |
39 | {!! __('I agree to the :terms_of_service and :privacy_policy', [ 40 | 'terms_of_service' => ''.__('Terms of Service').'', 41 | 'privacy_policy' => ''.__('Privacy Policy').'', 42 | ]) !!} 43 |
44 |
45 |
46 |
47 | @endif 48 | 49 |
50 | 51 | {{ __('Already registered?') }} 52 | 53 | 54 | 55 | {{ __('Register') }} 56 | 57 |
58 |
59 |
60 |
61 | -------------------------------------------------------------------------------- /resources/views/auth/reset-password.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | @csrf 11 | 12 | 13 | 14 |
15 | 16 | 17 |
18 | 19 |
20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 |
28 | 29 |
30 | 31 | {{ __('Reset Password') }} 32 | 33 |
34 |
35 |
36 |
37 | -------------------------------------------------------------------------------- /resources/views/auth/two-factor-challenge.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 | {{ __('Please confirm access to your account by entering the authentication code provided by your authenticator application.') }} 10 |
11 | 12 |
13 | {{ __('Please confirm access to your account by entering one of your emergency recovery codes.') }} 14 |
15 | 16 | 17 | 18 |
19 | @csrf 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 |
30 | 31 |
32 | 40 | 41 | 49 | 50 | 51 | {{ __('Log in') }} 52 | 53 |
54 |
55 |
56 |
57 |
58 | -------------------------------------------------------------------------------- /resources/views/auth/verify-email.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | {{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }} 9 |
10 | 11 | @if (session('status') == 'verification-link-sent') 12 |
13 | {{ __('A new verification link has been sent to the email address you provided during registration.') }} 14 |
15 | @endif 16 | 17 |
18 |
19 | @csrf 20 | 21 |
22 | 23 | {{ __('Resend Verification Email') }} 24 | 25 |
26 |
27 | 28 |
29 | @csrf 30 | 31 | 34 |
35 |
36 |
37 |
38 | -------------------------------------------------------------------------------- /resources/views/dashboard.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | {{ __('Dashboard') }} 5 |

6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ config('app.name', 'Laravel') }} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | @livewireStyles 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | @livewire('navigation-menu') 26 | 27 | 28 | @if (isset($header)) 29 |
30 |
31 | {{ $header }} 32 |
33 |
34 | @endif 35 | 36 | 37 |
38 | {{ $slot }} 39 |
40 |
41 | 42 | @stack('modals') 43 | 44 | @livewireScripts 45 | 46 | 47 | -------------------------------------------------------------------------------- /resources/views/layouts/guest.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ config('app.name', 'Laravel') }} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | {{ $slot }} 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /resources/views/policy.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 | 6 |
7 | 8 |
9 | {!! $policy !!} 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /resources/views/profile/delete-user-form.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ __('Delete Account') }} 4 | 5 | 6 | 7 | {{ __('Permanently delete your account.') }} 8 | 9 | 10 | 11 |
12 | {{ __('Once your account is deleted, all of its resources and data will be permanently deleted. Before deleting your account, please download any data or information that you wish to retain.') }} 13 |
14 | 15 |
16 | 17 | {{ __('Delete Account') }} 18 | 19 |
20 | 21 | 22 | 23 | 24 | {{ __('Delete Account') }} 25 | 26 | 27 | 28 | {{ __('Are you sure you want to delete your account? Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.') }} 29 | 30 |
31 | 36 | 37 | 38 |
39 |
40 | 41 | 42 | 43 | {{ __('Cancel') }} 44 | 45 | 46 | 47 | {{ __('Delete Account') }} 48 | 49 | 50 |
51 |
52 |
53 | -------------------------------------------------------------------------------- /resources/views/profile/show.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | {{ __('Profile') }} 5 |

6 |
7 | 8 |
9 |
10 | @if (Laravel\Fortify\Features::canUpdateProfileInformation()) 11 | @livewire('profile.update-profile-information-form') 12 | 13 | 14 | @endif 15 | 16 | @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::updatePasswords())) 17 |
18 | @livewire('profile.update-password-form') 19 |
20 | 21 | 22 | @endif 23 | 24 | @if (Laravel\Fortify\Features::canManageTwoFactorAuthentication()) 25 |
26 | @livewire('profile.two-factor-authentication-form') 27 |
28 | 29 | 30 | @endif 31 | 32 |
33 | @livewire('profile.logout-other-browser-sessions-form') 34 |
35 | 36 | @if (Laravel\Jetstream\Jetstream::hasAccountDeletionFeatures()) 37 | 38 | 39 |
40 | @livewire('profile.delete-user-form') 41 |
42 | @endif 43 |
44 |
45 |
46 | -------------------------------------------------------------------------------- /resources/views/profile/two-factor-authentication-form.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ __('Two Factor Authentication') }} 4 | 5 | 6 | 7 | {{ __('Add additional security to your account using two factor authentication.') }} 8 | 9 | 10 | 11 |

12 | @if ($this->enabled) 13 | {{ __('You have enabled two factor authentication.') }} 14 | @else 15 | {{ __('You have not enabled two factor authentication.') }} 16 | @endif 17 |

18 | 19 |
20 |

21 | {{ __('When two factor authentication is enabled, you will be prompted for a secure, random token during authentication. You may retrieve this token from your phone\'s Google Authenticator application.') }} 22 |

23 |
24 | 25 | @if ($this->enabled) 26 | @if ($showingQrCode) 27 |
28 |

29 | {{ __('Two factor authentication is now enabled. Scan the following QR code using your phone\'s authenticator application.') }} 30 |

31 |
32 | 33 |
34 | {!! $this->user->twoFactorQrCodeSvg() !!} 35 |
36 | @endif 37 | 38 | @if ($showingRecoveryCodes) 39 |
40 |

41 | {{ __('Store these recovery codes in a secure password manager. They can be used to recover access to your account if your two factor authentication device is lost.') }} 42 |

43 |
44 | 45 |
46 | @foreach (json_decode(decrypt($this->user->two_factor_recovery_codes), true) as $code) 47 |
{{ $code }}
48 | @endforeach 49 |
50 | @endif 51 | @endif 52 | 53 |
54 | @if (! $this->enabled) 55 | 56 | 57 | {{ __('Enable') }} 58 | 59 | 60 | @else 61 | @if ($showingRecoveryCodes) 62 | 63 | 64 | {{ __('Regenerate Recovery Codes') }} 65 | 66 | 67 | @else 68 | 69 | 70 | {{ __('Show Recovery Codes') }} 71 | 72 | 73 | @endif 74 | 75 | 76 | 77 | {{ __('Disable') }} 78 | 79 | 80 | @endif 81 |
82 |
83 |
84 | -------------------------------------------------------------------------------- /resources/views/profile/update-password-form.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ __('Update Password') }} 4 | 5 | 6 | 7 | {{ __('Ensure your account is using a long, random password to stay secure.') }} 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 | 27 |
28 |
29 | 30 | 31 | 32 | {{ __('Saved.') }} 33 | 34 | 35 | 36 | {{ __('Save') }} 37 | 38 | 39 |
40 | -------------------------------------------------------------------------------- /resources/views/profile/update-profile-information-form.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ __('Profile Information') }} 4 | 5 | 6 | 7 | {{ __('Update your account\'s profile information and email address.') }} 8 | 9 | 10 | 11 | 12 | @if (Laravel\Jetstream\Jetstream::managesProfilePhotos()) 13 |
14 | 15 | 26 | 27 | 28 | 29 | 30 |
31 | {{ $this->user->name }} 32 |
33 | 34 | 35 | 40 | 41 | 42 | {{ __('Select A New Photo') }} 43 | 44 | 45 | @if ($this->user->profile_photo_path) 46 | 47 | {{ __('Remove Photo') }} 48 | 49 | @endif 50 | 51 | 52 |
53 | @endif 54 | 55 | 56 |
57 | 58 | 59 | 60 |
61 | 62 | 63 |
64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 | {{ __('Saved.') }} 73 | 74 | 75 | 76 | {{ __('Save') }} 77 | 78 | 79 |
80 | -------------------------------------------------------------------------------- /resources/views/terms.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 | 6 |
7 | 8 |
9 | {!! $terms !!} 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/action-message.blade.php: -------------------------------------------------------------------------------- 1 | @props(['on']) 2 | 3 |
merge(['class' => 'text-sm text-gray-600']) }}> 9 | {{ $slot->isEmpty() ? 'Saved.' : $slot }} 10 |
11 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/action-section.blade.php: -------------------------------------------------------------------------------- 1 |
merge(['class' => 'md:grid md:grid-cols-3 md:gap-6']) }}> 2 | 3 | {{ $title }} 4 | {{ $description }} 5 | 6 | 7 |
8 |
9 | {{ $content }} 10 |
11 |
12 |
13 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/application-logo.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/application-mark.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/authentication-card-logo.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/authentication-card.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{ $logo }} 4 |
5 | 6 |
7 | {{ $slot }} 8 |
9 |
10 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/banner.blade.php: -------------------------------------------------------------------------------- 1 | @props(['style' => session('flash.bannerStyle', 'success'), 'message' => session('flash.banner')]) 2 | 3 |
14 |
15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

30 |
31 | 32 |
33 | 43 |
44 |
45 |
46 |
47 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/button.blade.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/checkbox.blade.php: -------------------------------------------------------------------------------- 1 | merge(['class' => 'rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50']) !!}> 2 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/confirmation-modal.blade.php: -------------------------------------------------------------------------------- 1 | @props(['id' => null, 'maxWidth' => null]) 2 | 3 | 4 |
5 |
6 |
7 | 8 | 9 | 10 |
11 | 12 |
13 |

14 | {{ $title }} 15 |

16 | 17 |
18 | {{ $content }} 19 |
20 |
21 |
22 |
23 | 24 |
25 | {{ $footer }} 26 |
27 |
28 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/confirms-password.blade.php: -------------------------------------------------------------------------------- 1 | @props(['title' => __('Confirm Password'), 'content' => __('For your security, please confirm your password to continue.'), 'button' => __('Confirm')]) 2 | 3 | @php 4 | $confirmableId = md5($attributes->wire('then')); 5 | @endphp 6 | 7 | wire('then') }} 9 | x-data 10 | x-ref="span" 11 | x-on:click="$wire.startConfirmingPassword('{{ $confirmableId }}')" 12 | x-on:password-confirmed.window="setTimeout(() => $event.detail.id === '{{ $confirmableId }}' && $refs.span.dispatchEvent(new CustomEvent('then', { bubbles: false })), 250);" 13 | > 14 | {{ $slot }} 15 | 16 | 17 | @once 18 | 19 | 20 | {{ $title }} 21 | 22 | 23 | 24 | {{ $content }} 25 | 26 |
27 | 31 | 32 | 33 |
34 |
35 | 36 | 37 | 38 | {{ __('Cancel') }} 39 | 40 | 41 | 42 | {{ $button }} 43 | 44 | 45 |
46 | @endonce 47 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/danger-button.blade.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/dialog-modal.blade.php: -------------------------------------------------------------------------------- 1 | @props(['id' => null, 'maxWidth' => null]) 2 | 3 | 4 |
5 |
6 | {{ $title }} 7 |
8 | 9 |
10 | {{ $content }} 11 |
12 |
13 | 14 |
15 | {{ $footer }} 16 |
17 |
18 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/dropdown-link.blade.php: -------------------------------------------------------------------------------- 1 | merge(['class' => 'block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition']) }}>{{ $slot }} 2 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/dropdown.blade.php: -------------------------------------------------------------------------------- 1 | @props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white', 'dropdownClasses' => '']) 2 | 3 | @php 4 | switch ($align) { 5 | case 'left': 6 | $alignmentClasses = 'origin-top-left left-0'; 7 | break; 8 | case 'top': 9 | $alignmentClasses = 'origin-top'; 10 | break; 11 | case 'none': 12 | case 'false': 13 | $alignmentClasses = ''; 14 | break; 15 | case 'right': 16 | default: 17 | $alignmentClasses = 'origin-top-right right-0'; 18 | break; 19 | } 20 | 21 | switch ($width) { 22 | case '48': 23 | $width = 'w-48'; 24 | break; 25 | } 26 | @endphp 27 | 28 |
29 |
30 | {{ $trigger }} 31 |
32 | 33 | 47 |
48 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/form-section.blade.php: -------------------------------------------------------------------------------- 1 | @props(['submit']) 2 | 3 |
merge(['class' => 'md:grid md:grid-cols-3 md:gap-6']) }}> 4 | 5 | {{ $title }} 6 | {{ $description }} 7 | 8 | 9 |
10 |
11 |
12 |
13 | {{ $form }} 14 |
15 |
16 | 17 | @if (isset($actions)) 18 |
19 | {{ $actions }} 20 |
21 | @endif 22 |
23 |
24 |
25 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/input-error.blade.php: -------------------------------------------------------------------------------- 1 | @props(['for']) 2 | 3 | @error($for) 4 |

merge(['class' => 'text-sm text-red-600']) }}>{{ $message }}

5 | @enderror 6 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/input.blade.php: -------------------------------------------------------------------------------- 1 | @props(['disabled' => false]) 2 | 3 | merge(['class' => 'border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm']) !!}> 4 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/label.blade.php: -------------------------------------------------------------------------------- 1 | @props(['value']) 2 | 3 | 6 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/modal.blade.php: -------------------------------------------------------------------------------- 1 | @props(['id', 'maxWidth']) 2 | 3 | @php 4 | $id = $id ?? md5($attributes->wire('model')); 5 | 6 | $maxWidth = [ 7 | 'sm' => 'sm:max-w-sm', 8 | 'md' => 'sm:max-w-md', 9 | 'lg' => 'sm:max-w-lg', 10 | 'xl' => 'sm:max-w-xl', 11 | '2xl' => 'sm:max-w-2xl', 12 | ][$maxWidth ?? '2xl']; 13 | @endphp 14 | 15 | 69 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/nav-link.blade.php: -------------------------------------------------------------------------------- 1 | @props(['active']) 2 | 3 | @php 4 | $classes = ($active ?? false) 5 | ? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition' 6 | : 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition'; 7 | @endphp 8 | 9 | merge(['class' => $classes]) }}> 10 | {{ $slot }} 11 | 12 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/responsive-nav-link.blade.php: -------------------------------------------------------------------------------- 1 | @props(['active']) 2 | 3 | @php 4 | $classes = ($active ?? false) 5 | ? 'block pl-3 pr-4 py-2 border-l-4 border-indigo-400 text-base font-medium text-indigo-700 bg-indigo-50 focus:outline-none focus:text-indigo-800 focus:bg-indigo-100 focus:border-indigo-700 transition' 6 | : 'block pl-3 pr-4 py-2 border-l-4 border-transparent text-base font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 hover:border-gray-300 focus:outline-none focus:text-gray-800 focus:bg-gray-50 focus:border-gray-300 transition'; 7 | @endphp 8 | 9 | merge(['class' => $classes]) }}> 10 | {{ $slot }} 11 | 12 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/secondary-button.blade.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/section-border.blade.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/section-title.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |

{{ $title }}

4 | 5 |

6 | {{ $description }} 7 |

8 |
9 | 10 |
11 | {{ $aside ?? '' }} 12 |
13 |
14 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/switchable-team.blade.php: -------------------------------------------------------------------------------- 1 | @props(['team', 'component' => 'jet-dropdown-link']) 2 | 3 |
4 | @method('PUT') 5 | @csrf 6 | 7 | 8 | 9 | 10 | 11 |
12 | @if (Auth::user()->isCurrentTeam($team)) 13 | 14 | @endif 15 | 16 |
{{ $team->name }}
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/components/validation-errors.blade.php: -------------------------------------------------------------------------------- 1 | @if ($errors->any()) 2 |
3 |
{{ __('Whoops! Something went wrong.') }}
4 | 5 |
    6 | @foreach ($errors->all() as $error) 7 |
  • {{ $error }}
  • 8 | @endforeach 9 |
10 |
11 | @endif 12 | -------------------------------------------------------------------------------- /resources/views/vendor/jetstream/mail/team-invitation.blade.php: -------------------------------------------------------------------------------- 1 | @component('mail::message') 2 | {{ __('You have been invited to join the :team team!', ['team' => $invitation->team->name]) }} 3 | 4 | @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::registration())) 5 | {{ __('If you do not have an account, you may create one by clicking the button below. After creating an account, you may click the invitation acceptance button in this email to accept the team invitation:') }} 6 | 7 | @component('mail::button', ['url' => route('register')]) 8 | {{ __('Create Account') }} 9 | @endcomponent 10 | 11 | {{ __('If you already have an account, you may accept this invitation by clicking the button below:') }} 12 | 13 | @else 14 | {{ __('You may accept this invitation by clicking the button below:') }} 15 | @endif 16 | 17 | 18 | @component('mail::button', ['url' => $acceptUrl]) 19 | {{ __('Accept Invitation') }} 20 | @endcomponent 21 | 22 | {{ __('If you did not expect to receive an invitation to this team, you may discard this email.') }} 23 | @endcomponent 24 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | name("root",); 10 | 11 | Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () { 12 | return view('dashboard'); 13 | })->name('dashboard'); 14 | 15 | Route::resource(name: 'users', controller: \App\Http\Controllers\UserController::class); 16 | 17 | Route::get('/sessions', [SessionController::class, 'index'])->name('sessions.index'); 18 | 19 | Route::get('/clear-cache', function() { 20 | $configCache = Artisan::call('config:cache'); 21 | $clearCache = Artisan::call('cache:clear'); 22 | return "Cache cleared"; 23 | }); -------------------------------------------------------------------------------- /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 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | const defaultTheme = require('tailwindcss/defaultTheme'); 2 | 3 | module.exports = { 4 | content: [ 5 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', 6 | './vendor/laravel/jetstream/**/*.blade.php', 7 | './storage/framework/views/*.php', 8 | './resources/views/**/*.blade.php', 9 | ], 10 | 11 | theme: { 12 | extend: { 13 | fontFamily: { 14 | sans: ['Nunito', ...defaultTheme.fontFamily.sans], 15 | }, 16 | }, 17 | }, 18 | 19 | plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')], 20 | }; 21 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Feature/ApiTokenPermissionsTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('API support is not enabled.'); 21 | } 22 | 23 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 24 | 25 | $token = $user->tokens()->create([ 26 | 'name' => 'Test Token', 27 | 'token' => Str::random(40), 28 | 'abilities' => ['create', 'read'], 29 | ]); 30 | 31 | Livewire::test(ApiTokenManager::class) 32 | ->set(['managingPermissionsFor' => $token]) 33 | ->set(['updateApiTokenForm' => [ 34 | 'permissions' => [ 35 | 'delete', 36 | 'missing-permission', 37 | ], 38 | ]]) 39 | ->call('updateApiToken'); 40 | 41 | $this->assertTrue($user->fresh()->tokens->first()->can('delete')); 42 | $this->assertFalse($user->fresh()->tokens->first()->can('read')); 43 | $this->assertFalse($user->fresh()->tokens->first()->can('missing-permission')); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/Feature/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get('/login'); 18 | 19 | $response->assertResponseStatus(200); 20 | } 21 | 22 | public function test_users_can_authenticate_using_the_login_screen() 23 | { 24 | $user = User::factory()->create(); 25 | 26 | $response = $this->post('/login', [ 27 | 'email' => $user->email, 28 | 'password' => 'password', 29 | ]); 30 | 31 | $this->assertAuthenticated(); 32 | $response->assertRedirectedToRoute('dashboard'); 33 | } 34 | 35 | public function test_users_can_not_authenticate_with_invalid_password() 36 | { 37 | $user = User::factory()->create(); 38 | 39 | $this->post('/login', [ 40 | 'email' => $user->email, 41 | 'password' => 'wrong-password', 42 | ]); 43 | 44 | $this->assertGuest(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/Feature/BrowserSessionsTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()); 18 | 19 | Livewire::test(LogoutOtherBrowserSessionsForm::class) 20 | ->set('password', 'password') 21 | ->call('logoutOtherBrowserSessions'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/Feature/CreateApiTokenTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('API support is not enabled.'); 20 | } 21 | 22 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 23 | 24 | Livewire::test(ApiTokenManager::class) 25 | ->set(['createApiTokenForm' => [ 26 | 'name' => 'Test Token', 27 | 'permissions' => [ 28 | 'read', 29 | 'update', 30 | ], 31 | ]]) 32 | ->call('createApiToken'); 33 | 34 | $this->assertCount(1, $user->fresh()->tokens); 35 | $this->assertEquals('Test Token', $user->fresh()->tokens->first()->name); 36 | $this->assertTrue($user->fresh()->tokens->first()->can('read')); 37 | $this->assertFalse($user->fresh()->tokens->first()->can('delete')); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/Feature/DeleteAccountTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Account deletion is not enabled.'); 20 | } 21 | 22 | $this->actingAs($user = User::factory()->create()); 23 | 24 | $component = Livewire::test(DeleteUserForm::class) 25 | ->set('password', 'password') 26 | ->call('deleteUser'); 27 | 28 | $this->assertNull($user->fresh()); 29 | } 30 | 31 | public function test_correct_password_must_be_provided_before_account_can_be_deleted() 32 | { 33 | if (! Features::hasAccountDeletionFeatures()) { 34 | return $this->markTestSkipped('Account deletion is not enabled.'); 35 | } 36 | 37 | $this->actingAs($user = User::factory()->create()); 38 | 39 | Livewire::test(DeleteUserForm::class) 40 | ->set('password', 'wrong-password') 41 | ->call('deleteUser') 42 | ->assertHasErrors(['password']); 43 | 44 | $this->assertNotNull($user->fresh()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/Feature/DeleteApiTokenTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('API support is not enabled.'); 21 | } 22 | 23 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 24 | 25 | $token = $user->tokens()->create([ 26 | 'name' => 'Test Token', 27 | 'token' => Str::random(40), 28 | 'abilities' => ['create', 'read'], 29 | ]); 30 | 31 | Livewire::test(ApiTokenManager::class) 32 | ->set(['apiTokenIdBeingDeleted' => $token->id]) 33 | ->call('deleteApiToken'); 34 | 35 | $this->assertCount(0, $user->fresh()->tokens); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/Feature/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Email verification not enabled.'); 22 | } 23 | 24 | $user = User::factory()->withPersonalTeam()->unverified()->create(); 25 | 26 | $response = $this->actingAs($user)->get('/email/verify'); 27 | 28 | $response->assertStatus(200); 29 | } 30 | 31 | public function test_email_can_be_verified() 32 | { 33 | if (! Features::enabled(Features::emailVerification())) { 34 | return $this->markTestSkipped('Email verification not enabled.'); 35 | } 36 | 37 | Event::fake(); 38 | 39 | $user = User::factory()->unverified()->create(); 40 | 41 | $verificationUrl = URL::temporarySignedRoute( 42 | 'verification.verify', 43 | now()->addMinutes(60), 44 | ['id' => $user->id, 'hash' => sha1($user->email)] 45 | ); 46 | 47 | $response = $this->actingAs($user)->get($verificationUrl); 48 | 49 | Event::assertDispatched(Verified::class); 50 | 51 | $this->assertTrue($user->fresh()->hasVerifiedEmail()); 52 | $response->assertRedirect(RouteServiceProvider::HOME.'?verified=1'); 53 | } 54 | 55 | public function test_email_can_not_verified_with_invalid_hash() 56 | { 57 | if (! Features::enabled(Features::emailVerification())) { 58 | return $this->markTestSkipped('Email verification not enabled.'); 59 | } 60 | 61 | $user = User::factory()->unverified()->create(); 62 | 63 | $verificationUrl = URL::temporarySignedRoute( 64 | 'verification.verify', 65 | now()->addMinutes(60), 66 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 67 | ); 68 | 69 | $this->actingAs($user)->get($verificationUrl); 70 | 71 | $this->assertFalse($user->fresh()->hasVerifiedEmail()); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertResponseStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Feature/PasswordConfirmationTest.php: -------------------------------------------------------------------------------- 1 | withPersonalTeam()->create(); 17 | 18 | $response = $this->actingAs($user)->get('/user/confirm-password'); 19 | 20 | $response->assertResponseStatus(200); 21 | } 22 | 23 | /** 24 | * @TODO: This test is failing 25 | */ 26 | public function test_password_can_be_confirmed() 27 | { 28 | $user = User::factory()->create(); 29 | 30 | $response = $this->actingAs($user)->post('/user/confirm-password', [ 31 | 'password' => 'password', 32 | ]); 33 | 34 | $this->markTestIncomplete( 35 | 'This test has not been implemented yet.' 36 | ); 37 | // $response->assertRedirect(); 38 | // $response->assertSessionHasNoErrors(); 39 | } 40 | 41 | public function test_password_is_not_confirmed_with_invalid_password() 42 | { 43 | $user = User::factory()->create(); 44 | 45 | $response = $this->actingAs($user)->post('/user/confirm-password', [ 46 | 'password' => 'wrong-password', 47 | ]); 48 | 49 | $response->assertSessionHasErrors(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /tests/Feature/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Password updates are not enabled.'); 20 | } 21 | 22 | $response = $this->get('/forgot-password'); 23 | 24 | $response->assertResponseStatus(200); 25 | } 26 | 27 | public function test_reset_password_link_can_be_requested() 28 | { 29 | if (! Features::enabled(Features::resetPasswords())) { 30 | return $this->markTestSkipped('Password updates are not enabled.'); 31 | } 32 | 33 | Notification::fake(); 34 | 35 | $user = User::factory()->create(); 36 | 37 | $response = $this->post('/forgot-password', [ 38 | 'email' => $user->email, 39 | ]); 40 | 41 | Notification::assertSentTo($user, ResetPassword::class); 42 | } 43 | 44 | public function test_reset_password_screen_can_be_rendered() 45 | { 46 | if (! Features::enabled(Features::resetPasswords())) { 47 | return $this->markTestSkipped('Password updates are not enabled.'); 48 | } 49 | 50 | Notification::fake(); 51 | 52 | $user = User::factory()->create(); 53 | 54 | $response = $this->post('/forgot-password', [ 55 | 'email' => $user->email, 56 | ]); 57 | 58 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) { 59 | $response = $this->get('/reset-password/'.$notification->token); 60 | 61 | $response->assertResponseStatus(200); 62 | 63 | return true; 64 | }); 65 | } 66 | 67 | public function test_password_can_be_reset_with_valid_token() 68 | { 69 | if (! Features::enabled(Features::resetPasswords())) { 70 | return $this->markTestSkipped('Password updates are not enabled.'); 71 | } 72 | 73 | Notification::fake(); 74 | 75 | $user = User::factory()->create(); 76 | 77 | $response = $this->post('/forgot-password', [ 78 | 'email' => $user->email, 79 | ]); 80 | 81 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { 82 | $response = $this->post('/reset-password', [ 83 | 'token' => $notification->token, 84 | 'email' => $user->email, 85 | 'password' => 'password', 86 | 'password_confirmation' => 'password', 87 | ]); 88 | 89 | // $response->assertSessionHasNoErrors(); 90 | $this->markTestIncomplete( 91 | 'This test has not been implemented yet.' 92 | ); 93 | return true; 94 | }); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /tests/Feature/ProfileInformationTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()); 18 | 19 | $component = Livewire::test(UpdateProfileInformationForm::class); 20 | 21 | $this->assertEquals($user->name, $component->state['name']); 22 | $this->assertEquals($user->email, $component->state['email']); 23 | } 24 | 25 | public function test_profile_information_can_be_updated() 26 | { 27 | $this->actingAs($user = User::factory()->create()); 28 | 29 | Livewire::test(UpdateProfileInformationForm::class) 30 | ->set('state', ['name' => 'Test Name', 'email' => 'test@example.com']) 31 | ->call('updateProfileInformation'); 32 | 33 | $this->assertEquals('Test Name', $user->fresh()->name); 34 | $this->assertEquals('test@example.com', $user->fresh()->email); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/Feature/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Registration support is not enabled.'); 19 | } 20 | 21 | $response = $this->get('/register'); 22 | 23 | $response->assertResponseStatus(200); 24 | } 25 | 26 | public function test_registration_screen_cannot_be_rendered_if_support_is_disabled() 27 | { 28 | if (Features::enabled(Features::registration())) { 29 | return $this->markTestSkipped('Registration support is enabled.'); 30 | } 31 | 32 | $response = $this->get('/register'); 33 | 34 | $response->assertStatus(404); 35 | } 36 | 37 | public function test_new_users_can_register() 38 | { 39 | if (! Features::enabled(Features::registration())) { 40 | return $this->markTestSkipped('Registration support is not enabled.'); 41 | } 42 | 43 | $response = $this->post('/register', [ 44 | 'name' => 'Test User', 45 | 'email' => 'test@example.com', 46 | 'password' => 'password', 47 | 'password_confirmation' => 'password', 48 | 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(), 49 | ]); 50 | 51 | $this->markTestIncomplete( 52 | 'This test has not been implemented yet.' 53 | ); 54 | // $this->assertAuthenticated(); 55 | 56 | $response->assertRedirect(RouteServiceProvider::HOME); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /tests/Feature/TwoFactorAuthenticationSettingsTest.php: -------------------------------------------------------------------------------- 1 | markTestIncomplete( 18 | 'This test has not been implemented yet.' 19 | ); 20 | 21 | $this->actingAs($user = User::factory()->create()); 22 | 23 | $this->withSession(['auth.password_confirmed_at' => time()]); 24 | 25 | Livewire::test(TwoFactorAuthenticationForm::class) 26 | ->call('enableTwoFactorAuthentication'); 27 | 28 | $user = $user->fresh(); 29 | 30 | $this->assertNotNull($user->two_factor_secret); 31 | $this->assertCount(8, $user->recoveryCodes()); 32 | } 33 | 34 | public function test_recovery_codes_can_be_regenerated() 35 | { 36 | $this->markTestIncomplete( 37 | 'This test has not been implemented yet.' 38 | ); 39 | $this->actingAs($user = User::factory()->create()); 40 | 41 | $this->withSession(['auth.password_confirmed_at' => time()]); 42 | 43 | $component = Livewire::test(TwoFactorAuthenticationForm::class) 44 | ->call('enableTwoFactorAuthentication') 45 | ->call('regenerateRecoveryCodes'); 46 | 47 | $user = $user->fresh(); 48 | 49 | $component->call('regenerateRecoveryCodes'); 50 | 51 | $this->assertCount(8, $user->recoveryCodes()); 52 | $this->assertCount(8, array_diff($user->recoveryCodes(), $user->fresh()->recoveryCodes())); 53 | } 54 | 55 | public function test_two_factor_authentication_can_be_disabled() 56 | { 57 | $this->markTestIncomplete( 58 | 'This test has not been implemented yet.' 59 | ); 60 | 61 | $this->actingAs($user = User::factory()->create()); 62 | 63 | $this->withSession(['auth.password_confirmed_at' => time()]); 64 | 65 | $component = Livewire::test(TwoFactorAuthenticationForm::class) 66 | ->call('enableTwoFactorAuthentication'); 67 | 68 | $this->assertNotNull($user->fresh()->two_factor_secret); 69 | 70 | $component->call('disableTwoFactorAuthentication'); 71 | 72 | $this->assertNull($user->fresh()->two_factor_secret); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /tests/Feature/UpdatePasswordTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()); 19 | 20 | Livewire::test(UpdatePasswordForm::class) 21 | ->set('state', [ 22 | 'current_password' => 'password', 23 | 'password' => 'new-password', 24 | 'password_confirmation' => 'new-password', 25 | ]) 26 | ->call('updatePassword'); 27 | 28 | $this->assertTrue(Hash::check('new-password', $user->fresh()->password)); 29 | } 30 | 31 | public function test_current_password_must_be_correct() 32 | { 33 | $this->actingAs($user = User::factory()->create()); 34 | 35 | Livewire::test(UpdatePasswordForm::class) 36 | ->set('state', [ 37 | 'current_password' => 'wrong-password', 38 | 'password' => 'new-password', 39 | 'password_confirmation' => 'new-password', 40 | ]) 41 | ->call('updatePassword') 42 | ->assertHasErrors(['current_password']); 43 | 44 | $this->assertTrue(Hash::check('password', $user->fresh()->password)); 45 | } 46 | 47 | public function test_new_passwords_must_match() 48 | { 49 | $this->actingAs($user = User::factory()->create()); 50 | 51 | Livewire::test(UpdatePasswordForm::class) 52 | ->set('state', [ 53 | 'current_password' => 'password', 54 | 'password' => 'new-password', 55 | 'password_confirmation' => 'wrong-password', 56 | ]) 57 | ->call('updatePassword') 58 | ->assertHasErrors(['password']); 59 | 60 | $this->assertTrue(Hash::check('password', $user->fresh()->password)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | app->detectEnvironment( function () { 23 | return 'testing'; 24 | }); 25 | 26 | } 27 | 28 | public function tearDown() : void 29 | { 30 | parent::tearDown(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel applications. By default, we are compiling the CSS 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .postCss('resources/css/app.css', 'public/css', [ 16 | require('postcss-import'), 17 | require('tailwindcss'), 18 | ]); 19 | 20 | if (mix.inProduction()) { 21 | mix.version(); 22 | } 23 | --------------------------------------------------------------------------------