├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── AuthenticatedSessionController.php │ │ │ ├── ConfirmablePasswordController.php │ │ │ ├── EmailVerificationNotificationController.php │ │ │ ├── EmailVerificationPromptController.php │ │ │ ├── NewPasswordController.php │ │ │ ├── PasswordController.php │ │ │ ├── PasswordResetLinkController.php │ │ │ ├── RegisteredUserController.php │ │ │ └── VerifyEmailController.php │ │ ├── Controller.php │ │ ├── GroupController.php │ │ ├── HomeController.php │ │ ├── PostController.php │ │ ├── ProfileController.php │ │ ├── SearchController.php │ │ └── UserController.php │ ├── Enums │ │ ├── GroupUserRole.php │ │ ├── GroupUserStatus.php │ │ └── ReactionEnum.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── HandleInertiaRequests.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── TrustProxies.php │ │ ├── ValidateSignature.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ ├── Auth │ │ │ └── LoginRequest.php │ │ ├── InviteUsersRequest.php │ │ ├── ProfileUpdateRequest.php │ │ ├── StoreGroupRequest.php │ │ ├── StorePostRequest.php │ │ ├── UpdateCommentRequest.php │ │ ├── UpdateGroupRequest.php │ │ └── UpdatePostRequest.php │ └── Resources │ │ ├── CommentResource.php │ │ ├── GroupResource.php │ │ ├── GroupUserResource.php │ │ ├── PostAttachmentResource.php │ │ ├── PostResource.php │ │ └── UserResource.php ├── Models │ ├── Comment.php │ ├── Follower.php │ ├── Group.php │ ├── GroupUser.php │ ├── Post.php │ ├── PostAttachment.php │ ├── Reaction.php │ └── User.php ├── Notifications │ ├── CommentCreated.php │ ├── CommentDeleted.php │ ├── FollowUser.php │ ├── InvitationApproved.php │ ├── InvitationInGroup.php │ ├── PostCreated.php │ ├── PostDeleted.php │ ├── ReactionAddedOnComment.php │ ├── ReactionAddedOnPost.php │ ├── RequestApproved.php │ ├── RequestToJoinGroup.php │ ├── RoleChanged.php │ └── UserRemovedFromGroup.php └── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── RouteServiceProvider.php │ └── TelescopeServiceProvider.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cors.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── openai.php ├── queue.php ├── sanctum.php ├── services.php ├── session.php ├── telescope.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2023_11_16_180010_create_groups_table.php │ ├── 2023_11_16_180012_create_group_users_table.php │ ├── 2023_11_16_180014_create_posts_table.php │ ├── 2023_11_16_180025_create_post_attachments_table.php │ ├── 2023_11_16_180038_create_post_reactions_table.php │ ├── 2023_11_16_180053_create_comments_table.php │ ├── 2023_11_16_180124_create_followers_table.php │ ├── 2023_11_16_184001_add_columns_to_users_table.php │ ├── 2023_11_28_205441_add_size_column_to_post_attachments_table.php │ ├── 2023_12_06_195921_change_post_reactions_table.php │ ├── 2023_12_06_210813_add_parent_id_to_comments.php │ ├── 2023_12_16_125648_add_preview_column_to_posts_table.php │ ├── 2023_12_16_145941_add_pinned_post_id_column_to_groups_and_users_tables.php │ └── 2023_12_23_113538_add_foreign_key_on_comments_table_for_parent_id.php └── seeders │ └── DatabaseSeeder.php ├── docker-compose.yml ├── docker ├── 8.0 │ ├── Dockerfile │ ├── php.ini │ ├── start-container │ └── supervisord.conf ├── 8.1 │ ├── Dockerfile │ ├── php.ini │ ├── start-container │ └── supervisord.conf ├── 8.2 │ ├── Dockerfile │ ├── php.ini │ ├── start-container │ └── supervisord.conf ├── 8.3 │ ├── Dockerfile │ ├── php.ini │ ├── start-container │ └── supervisord.conf ├── mysql │ └── create-testing-database.sh └── pgsql │ └── create-testing-database.sql ├── jsconfig.json ├── package-lock.json ├── package.json ├── phpunit.xml ├── postcss.config.js ├── public ├── .htaccess ├── favicon.ico ├── img │ ├── default_avatar.webp │ ├── default_cover.jpg │ └── no_image.png ├── index.php ├── robots.txt └── vendor │ └── telescope │ ├── app-dark.css │ ├── app.css │ ├── app.js │ ├── favicon.ico │ └── mix-manifest.json ├── resources ├── css │ └── app.css ├── js │ ├── Components │ │ ├── ApplicationLogo.vue │ │ ├── Checkbox.vue │ │ ├── DangerButton.vue │ │ ├── Dropdown.vue │ │ ├── DropdownLink.vue │ │ ├── InputError.vue │ │ ├── InputLabel.vue │ │ ├── InputTextarea.vue │ │ ├── Modal.vue │ │ ├── NavLink.vue │ │ ├── PrimaryButton.vue │ │ ├── ResponsiveNavLink.vue │ │ ├── SecondaryButton.vue │ │ ├── TextInput.vue │ │ └── app │ │ │ ├── AttachmentPreviewModal.vue │ │ │ ├── BaseModal.vue │ │ │ ├── CommentList.vue │ │ │ ├── CreatePost.vue │ │ │ ├── EditDeleteDropdown.vue │ │ │ ├── FollowingList.vue │ │ │ ├── FollowingListItems.vue │ │ │ ├── GroupForm.vue │ │ │ ├── GroupItem.vue │ │ │ ├── GroupList.vue │ │ │ ├── GroupListItems.vue │ │ │ ├── GroupModal.vue │ │ │ ├── IndigoButton.vue │ │ │ ├── PostAttachments.vue │ │ │ ├── PostItem.vue │ │ │ ├── PostList.vue │ │ │ ├── PostModal.vue │ │ │ ├── PostUserHeader.vue │ │ │ ├── ReadMoreReadLess.vue │ │ │ ├── UrlPreview.vue │ │ │ └── UserListItem.vue │ ├── Layouts │ │ ├── AuthenticatedLayout.vue │ │ └── GuestLayout.vue │ ├── Pages │ │ ├── Auth │ │ │ ├── ConfirmPassword.vue │ │ │ ├── ForgotPassword.vue │ │ │ ├── Login.vue │ │ │ ├── Register.vue │ │ │ ├── ResetPassword.vue │ │ │ └── VerifyEmail.vue │ │ ├── Error.vue │ │ ├── Group │ │ │ ├── InviteUserModal.vue │ │ │ └── View.vue │ │ ├── Home.vue │ │ ├── Post │ │ │ └── View.vue │ │ ├── Profile │ │ │ ├── Edit.vue │ │ │ ├── Partials │ │ │ │ ├── DeleteUserForm.vue │ │ │ │ ├── TabItem.vue │ │ │ │ ├── UpdatePasswordForm.vue │ │ │ │ └── UpdateProfileInformationForm.vue │ │ │ ├── TabPhotos.vue │ │ │ └── View.vue │ │ └── Search.vue │ ├── app.js │ ├── axiosClient.js │ ├── bootstrap.js │ └── helpers.js └── views │ └── app.blade.php ├── routes ├── api.php ├── auth.php ├── channels.php ├── console.php └── web.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tailwind.config.js ├── tests ├── CreatesApplication.php ├── Feature │ ├── Auth │ │ ├── AuthenticationTest.php │ │ ├── EmailVerificationTest.php │ │ ├── PasswordConfirmationTest.php │ │ ├── PasswordResetTest.php │ │ ├── PasswordUpdateTest.php │ │ └── RegistrationTest.php │ ├── ExampleTest.php │ └── ProfileTest.php ├── Pest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── vite.config.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=laravel_social_media_website 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_APP_NAME="${APP_NAME}" 55 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 56 | VITE_PUSHER_HOST="${PUSHER_HOST}" 57 | VITE_PUSHER_PORT="${PUSHER_PORT}" 58 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 59 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 60 | 61 | OPENAI_API_KEY=sk-* 62 | OPENAI_ORGANIZATION=org-* 63 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | .styleci.yml export-ignore 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .env 9 | .env.backup 10 | .env.production 11 | .phpunit.result.cache 12 | Homestead.json 13 | Homestead.yaml 14 | auth.json 15 | npm-debug.log 16 | yarn-error.log 17 | /.fleet 18 | /.idea 19 | /.vscode 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Social Media Website 2 | Laravel Social Media Website built with Inertia Vue.js. The project was created during the following 48 hours YouTube Playlist [YouTube Tutorial](https://www.youtube.com/watch?v=4iiEyOKhvao&list=PLLQuc_7jk__Wa8IoZ2s0J-ql_MIisndtZ). 3 | 4 | ## Demo 5 | The application is deployed on the following domain [laravel-space.com](https://laravel-space.com/) 6 | 7 | ## Installation with docker 8 | 9 | #### 1. Clone the project 10 | ```bash 11 | git clone https://github.com/thecodeholic/laravel-social-media-website.git 12 | ``` 13 | 14 | #### 2. Run `composer install` 15 | Navigate into project folder using terminal and run 16 | 17 | ```bash 18 | docker run --rm \ 19 | -u "$(id -u):$(id -g)" \ 20 | -v "$(pwd):/var/www/html" \ 21 | -w /var/www/html \ 22 | laravelsail/php83-composer:latest \ 23 | composer install --ignore-platform-reqs 24 | ``` 25 | 26 | #### 3. Copy `.env.example` into `.env` 27 | 28 | ```bash 29 | cp .env.example .env 30 | ``` 31 | 32 | #### 4. Start the project in detached mode 33 | 34 | ```bash 35 | ./vendor/bin/sail up -d 36 | ``` 37 | From now on whenever you want to run artisan command you should do this from the container.
38 | Access to the docker container 39 | ```bash 40 | ./vendor/bin/sail bash 41 | ``` 42 | 43 | #### 5. Set encryption key 44 | 45 | ```bash 46 | php artisan key:generate --ansi 47 | ``` 48 | 49 | #### 6. Run migrations 50 | 51 | ```bash 52 | php artisan migrate 53 | ``` 54 | 55 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $dontFlash = [ 16 | 'current_password', 17 | 'password', 18 | 'password_confirmation', 19 | ]; 20 | 21 | /** 22 | * Register the exception handling callbacks for the application. 23 | */ 24 | public function register(): void 25 | { 26 | $this->reportable(function (Throwable $e) { 27 | // 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | Route::has('password.request'), 24 | 'status' => session('status'), 25 | ]); 26 | } 27 | 28 | /** 29 | * Handle an incoming authentication request. 30 | */ 31 | public function store(LoginRequest $request): RedirectResponse 32 | { 33 | $request->authenticate(); 34 | 35 | $request->session()->regenerate(); 36 | 37 | return redirect()->intended(RouteServiceProvider::HOME); 38 | } 39 | 40 | /** 41 | * Destroy an authenticated session. 42 | */ 43 | public function destroy(Request $request): RedirectResponse 44 | { 45 | Auth::guard('web')->logout(); 46 | 47 | $request->session()->invalidate(); 48 | 49 | $request->session()->regenerateToken(); 50 | 51 | return redirect('/'); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ConfirmablePasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 30 | 'email' => $request->user()->email, 31 | 'password' => $request->password, 32 | ])) { 33 | throw ValidationException::withMessages([ 34 | 'password' => __('auth.password'), 35 | ]); 36 | } 37 | 38 | $request->session()->put('auth.password_confirmed_at', time()); 39 | 40 | return redirect()->intended(RouteServiceProvider::HOME); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationNotificationController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 18 | return redirect()->intended(RouteServiceProvider::HOME); 19 | } 20 | 21 | $request->user()->sendEmailVerificationNotification(); 22 | 23 | return back()->with('status', 'verification-link-sent'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationPromptController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail() 20 | ? redirect()->intended(RouteServiceProvider::HOME) 21 | : Inertia::render('Auth/VerifyEmail', ['status' => session('status')]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/NewPasswordController.php: -------------------------------------------------------------------------------- 1 | $request->email, 26 | 'token' => $request->route('token'), 27 | ]); 28 | } 29 | 30 | /** 31 | * Handle an incoming new password request. 32 | * 33 | * @throws \Illuminate\Validation\ValidationException 34 | */ 35 | public function store(Request $request): RedirectResponse 36 | { 37 | $request->validate([ 38 | 'token' => 'required', 39 | 'email' => 'required|email', 40 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 41 | ]); 42 | 43 | // Here we will attempt to reset the user's password. If it is successful we 44 | // will update the password on an actual user model and persist it to the 45 | // database. Otherwise we will parse the error and return the response. 46 | $status = Password::reset( 47 | $request->only('email', 'password', 'password_confirmation', 'token'), 48 | function ($user) use ($request) { 49 | $user->forceFill([ 50 | 'password' => Hash::make($request->password), 51 | 'remember_token' => Str::random(60), 52 | ])->save(); 53 | 54 | event(new PasswordReset($user)); 55 | } 56 | ); 57 | 58 | // If the password was successfully reset, we will redirect the user back to 59 | // the application's home authenticated view. If there is an error we can 60 | // redirect them back to where they came from with their error message. 61 | if ($status == Password::PASSWORD_RESET) { 62 | return redirect()->route('login')->with('status', __($status)); 63 | } 64 | 65 | throw ValidationException::withMessages([ 66 | 'email' => [trans($status)], 67 | ]); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 19 | 'current_password' => ['required', 'current_password'], 20 | 'password' => ['required', Password::defaults(), 'confirmed'], 21 | ]); 22 | 23 | $request->user()->update([ 24 | 'password' => Hash::make($validated['password']), 25 | ]); 26 | 27 | return back(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordResetLinkController.php: -------------------------------------------------------------------------------- 1 | session('status'), 22 | ]); 23 | } 24 | 25 | /** 26 | * Handle an incoming password reset link request. 27 | * 28 | * @throws \Illuminate\Validation\ValidationException 29 | */ 30 | public function store(Request $request): RedirectResponse 31 | { 32 | $request->validate([ 33 | 'email' => 'required|email', 34 | ]); 35 | 36 | // We will send the password reset link to this user. Once we have attempted 37 | // to send the link, we will examine the response then see the message we 38 | // need to show to the user. Finally, we'll send out a proper response. 39 | $status = Password::sendResetLink( 40 | $request->only('email') 41 | ); 42 | 43 | if ($status == Password::RESET_LINK_SENT) { 44 | return back()->with('status', __($status)); 45 | } 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => [trans($status)], 49 | ]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisteredUserController.php: -------------------------------------------------------------------------------- 1 | validate([ 35 | 'name' => 'required|string|max:255', 36 | 'email' => 'required|string|lowercase|email|max:255|unique:'.User::class, 37 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 38 | ]); 39 | 40 | $user = User::create([ 41 | 'name' => $request->name, 42 | 'email' => $request->email, 43 | 'password' => Hash::make($request->password), 44 | ]); 45 | 46 | event(new Registered($user)); 47 | 48 | Auth::login($user); 49 | 50 | return redirect(RouteServiceProvider::HOME); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerifyEmailController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 19 | return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); 20 | } 21 | 22 | if ($request->user()->markEmailAsVerified()) { 23 | event(new Verified($request->user())); 24 | } 25 | 26 | return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | user(); 22 | $posts = Post::postsForTimeline($userId) 23 | ->select('posts.*') 24 | ->leftJoin('followers AS f', function ($join) use ($userId) { 25 | $join->on('posts.user_id', '=', 'f.user_id') 26 | ->where('f.follower_id', '=', $userId); 27 | }) 28 | ->leftJoin('group_users AS gu', function ($join) use ($userId) { 29 | $join->on('gu.group_id', '=', 'posts.group_id') 30 | ->where('gu.user_id', '=', $userId) 31 | ->where('gu.status', GroupUserStatus::APPROVED->value); 32 | }) 33 | ->where(function($query) use ($userId) { 34 | /** @var \Illuminate\Database\Query\Builder $query */ 35 | $query->whereNotNull('f.follower_id') 36 | ->orWhereNotNull('gu.group_id') 37 | ->orWhere('posts.user_id', $userId) 38 | ; 39 | }) 40 | // ->whereNot('posts.user_id', $userId) 41 | ->paginate(10); 42 | 43 | $posts = PostResource::collection($posts); 44 | if ($request->wantsJson()) { 45 | return $posts; 46 | } 47 | 48 | $groups = Group::query() 49 | ->with('currentUserGroup') 50 | ->select(['groups.*']) 51 | ->join('group_users AS gu', 'gu.group_id', 'groups.id') 52 | ->where('gu.user_id', Auth::id()) 53 | ->orderBy('gu.role') 54 | ->orderBy('name', 'desc') 55 | ->get(); 56 | 57 | 58 | return Inertia::render('Home', [ 59 | 'posts' => $posts, 60 | 'groups' => GroupResource::collection($groups), 61 | 'followings' => UserResource::collection($user->followings) 62 | ]); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/Http/Controllers/SearchController.php: -------------------------------------------------------------------------------- 1 | where('name', 'like', "%$search%") 23 | ->orWhere('username', 'like', "%$search%") 24 | ->latest() 25 | ->get(); 26 | 27 | $groups = Group::query() 28 | ->where('name', 'like', "%$search%") 29 | ->orWhere('about', 'like', "%$search%") 30 | ->latest() 31 | ->get(); 32 | 33 | $posts = Post::postsForTimeline(Auth::id()) 34 | ->where('body', 'like', "%$search%") 35 | ->paginate(20); 36 | 37 | $posts = PostResource::collection($posts); 38 | if ($request->wantsJson()) { 39 | return $posts; 40 | } 41 | 42 | 43 | return inertia('Search', [ 44 | 'posts' => $posts, 45 | 'search' => $search, 46 | 'users' => UserResource::collection($users), 47 | 'groups' => GroupResource::collection($groups) 48 | ]); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/Http/Controllers/UserController.php: -------------------------------------------------------------------------------- 1 | validate([ 16 | 'follow' => ['boolean'] 17 | ]); 18 | if ($data['follow']) { 19 | $message = 'You followed user "'.$user->name.'"'; 20 | Follower::create([ 21 | 'user_id' => $user->id, 22 | 'follower_id' => Auth::id() 23 | ]); 24 | } else { 25 | $message = 'You unfollowed user "'.$user->name.'"'; 26 | Follower::query() 27 | ->where('user_id', $user->id) 28 | ->where('follower_id', Auth::id()) 29 | ->delete(); 30 | } 31 | 32 | $user->notify(new FollowUser(Auth::getUser(), $data['follow'])); 33 | 34 | return back()->with('success', $message); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Http/Enums/GroupUserRole.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | 32 | */ 33 | public function share(Request $request): array 34 | { 35 | return [ 36 | ...parent::share($request), 37 | 'auth' => [ 38 | 'user' => $request->user() ? new UserResource($request->user()) : null, 39 | ], 40 | 'attachmentExtensions' => StorePostRequest::$extensions, 41 | 'ziggy' => fn () => [ 42 | ...(new Ziggy)->toArray(), 43 | 'location' => $request->url(), 44 | ], 45 | ]; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'email' => ['required', 'string', 'email'], 31 | 'password' => ['required', 'string'], 32 | ]; 33 | } 34 | 35 | /** 36 | * Attempt to authenticate the request's credentials. 37 | * 38 | * @throws \Illuminate\Validation\ValidationException 39 | */ 40 | public function authenticate(): void 41 | { 42 | $this->ensureIsNotRateLimited(); 43 | 44 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 45 | RateLimiter::hit($this->throttleKey()); 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => trans('auth.failed'), 49 | ]); 50 | } 51 | 52 | RateLimiter::clear($this->throttleKey()); 53 | } 54 | 55 | /** 56 | * Ensure the login request is not rate limited. 57 | * 58 | * @throws \Illuminate\Validation\ValidationException 59 | */ 60 | public function ensureIsNotRateLimited(): void 61 | { 62 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 63 | return; 64 | } 65 | 66 | event(new Lockout($this)); 67 | 68 | $seconds = RateLimiter::availableIn($this->throttleKey()); 69 | 70 | throw ValidationException::withMessages([ 71 | 'email' => trans('auth.throttle', [ 72 | 'seconds' => $seconds, 73 | 'minutes' => ceil($seconds / 60), 74 | ]), 75 | ]); 76 | } 77 | 78 | /** 79 | * Get the rate limiting throttle key for the request. 80 | */ 81 | public function throttleKey(): string 82 | { 83 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/Http/Requests/InviteUsersRequest.php: -------------------------------------------------------------------------------- 1 | group = $this->route('group'); 25 | 26 | return $this->group->isAdmin(Auth::id()); 27 | } 28 | 29 | /** 30 | * Get the validation rules that apply to the request. 31 | * 32 | * @return array|string> 33 | */ 34 | public function rules(): array 35 | { 36 | return [ 37 | 'email' => ['required', function ($attribute, $value, \Closure $fail) { 38 | $this->user = User::query()->where('email', $value) 39 | ->orWhere('username', $value) 40 | ->first(); 41 | 42 | if (!$this->user) { 43 | $fail('User does not exist'); 44 | } 45 | 46 | $this->groupUser = GroupUser::where('user_id', $this->user->id) 47 | ->where('group_id', $this->group->id) 48 | ->first(); 49 | 50 | if ($this->groupUser && $this->groupUser->status === GroupUserStatus::APPROVED->value) { 51 | $fail('User is already joined to the group'); 52 | } 53 | }] 54 | ]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Http/Requests/ProfileUpdateRequest.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function rules(): array 17 | { 18 | return [ 19 | 'name' => ['required', 'string', 'max:255'], 20 | 'username' => ['required', 'string', 'max:255', 'regex:/^[\w\-\.]+$/i'], 21 | 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)], 22 | ]; 23 | } 24 | 25 | public function messages() 26 | { 27 | return [ 28 | 'regex' => 'Username can only contain alphanumeric characters, dash (-) and dot(.).' 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Requests/StoreGroupRequest.php: -------------------------------------------------------------------------------- 1 | |string> 21 | */ 22 | public function rules(): array 23 | { 24 | return [ 25 | 'name' => ['required', 'max:255'], 26 | 'auto_approval' => ['required', 'boolean'], 27 | 'about' => ['nullable'] 28 | ]; 29 | } 30 | 31 | protected function passedValidation(): void 32 | { 33 | // Access the validated data using the validated() method 34 | $data = $this->validated(); 35 | 36 | // Modify the 'about' field, for example, convert it to uppercase 37 | $data['about'] = nl2br($data['about']); 38 | 39 | // Update the request data with the modified value 40 | $this->replace($data); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Http/Requests/UpdateCommentRequest.php: -------------------------------------------------------------------------------- 1 | route('comment'); 16 | 17 | return $comment->user_id == Auth::id(); 18 | } 19 | 20 | /** 21 | * Get the validation rules that apply to the request. 22 | * 23 | * @return array|string> 24 | */ 25 | public function rules(): array 26 | { 27 | return [ 28 | 'comment' => 'required' 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Requests/UpdateGroupRequest.php: -------------------------------------------------------------------------------- 1 | route('group'); 17 | 18 | return $group->isAdmin(Auth::id()); 19 | } 20 | 21 | /** 22 | * Get the validation rules that apply to the request. 23 | * 24 | * @return array|string> 25 | */ 26 | public function rules(): array 27 | { 28 | return [ 29 | 'name' => ['required', 'max:255'], 30 | 'auto_approval' => ['required', 'boolean'], 31 | 'about' => ['nullable'] 32 | ]; 33 | } 34 | 35 | protected function prepareForValidation(): void 36 | { 37 | $this->merge([ 38 | 'about' => nl2br($this->about), 39 | ]); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Http/Requests/UpdatePostRequest.php: -------------------------------------------------------------------------------- 1 | route('post'); 18 | 19 | return $post->user_id == Auth::id(); 20 | } 21 | 22 | public function rules(): array 23 | { 24 | $rules = parent::rules(); 25 | unset($rules['group_id']); 26 | 27 | return array_merge($rules, [ 28 | 'deleted_file_ids' => 'array', 29 | 'deleted_file_ids.*' => 'numeric', 30 | ]); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Resources/CommentResource.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function toArray(Request $request): array 17 | { 18 | return [ 19 | 'id' => $this->id, 20 | 'comment' => $this->comment, 21 | 'created_at' => $this->created_at->format('Y-m-d H:i:s'), 22 | 'updated_at' => $this->updated_at->format('Y-m-d H:i:s'), 23 | 'num_of_reactions' => $this->reactions_count, 24 | 'num_of_comments' => $this->numOfComments, 25 | 'current_user_has_reaction' => $this->reactions->count() > 0, 26 | 'comments' => $this->childComments, 27 | 'user' => [ 28 | "id" => $this->user->id, 29 | "name" => $this->user->name, 30 | "username" => $this->user->username, 31 | "avatar_url" => $this->user->avatar_path ? Storage::url($this->user->avatar_path) : '/img/default_avatar.webp', 32 | ] 33 | ]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Http/Resources/GroupResource.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | public function toArray(Request $request): array 18 | { 19 | return [ 20 | 'id' => $this->id, 21 | 'name' => $this->name, 22 | 'slug' => $this->slug, 23 | 'status' => $this->currentUserGroup?->status, 24 | 'role' => $this->currentUserGroup?->role, 25 | 'pinned_post_id' => $this->pinned_post_id, 26 | 'thumbnail_url' => $this->thumbnail_path ? Storage::url($this->thumbnail_path) : '/img/no_image.png', 27 | 'cover_url' => $this->cover_path ? Storage::url($this->cover_path) : null, 28 | 'auto_approval' => $this->auto_approval, 29 | 'about' => $this->about, 30 | 'description' => Str::words(strip_tags($this->about), 10), 31 | 'user_id' => $this->user_id, 32 | // 'deleted_at' => $this->deleted_at, 33 | // 'deleted_by' => $this->deleted_by, 34 | 'created_at' => $this->created_at, 35 | 'updated_at' => $this->updated_at, 36 | ]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Http/Resources/GroupUserResource.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function toArray(Request $request): array 17 | { 18 | return [ 19 | "id" => $this->id, 20 | "name" => $this->name, 21 | 'role' => $this->role, 22 | 'status' => $this->status, 23 | 'group_id' => $this->group_id, 24 | "username" => $this->username, 25 | "avatar_url" => $this->avatar_path ? Storage::url($this->avatar_path) : '/img/default_avatar.webp', 26 | ]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Resources/PostAttachmentResource.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function toArray(Request $request): array 17 | { 18 | return [ 19 | 'id' => $this->id, 20 | 'name' => $this->name, 21 | 'mime' => $this->mime, 22 | 'size' => $this->size, 23 | 'url' => Storage::url($this->path), 24 | 'created_at' => $this->created_at, 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Http/Resources/PostResource.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | public function toArray(Request $request): array 16 | { 17 | $comments = $this->comments; 18 | 19 | return [ 20 | 'id' => $this->id, 21 | 'body' => $this->body, 22 | 'preview' => $this->preview, 23 | 'preview_url' => $this->preview_url, 24 | 'created_at' => $this->created_at->format('Y-m-d H:i:s'), 25 | 'updated_at' => $this->updated_at->format('Y-m-d H:i:s'), 26 | 'user' => new UserResource($this->user), 27 | 'group' => new GroupResource($this->group), 28 | 'attachments' => PostAttachmentResource::collection($this->attachments), 29 | 'num_of_reactions' => $this->reactions_count, 30 | 'num_of_comments' => count($comments), 31 | 'current_user_has_reaction' => $this->reactions->count() > 0, 32 | 'comments' => self::convertCommentsIntoTree($comments) 33 | ]; 34 | } 35 | 36 | /** 37 | * 38 | * 39 | * @param \App\Models\Comment[] $comments 40 | * @param $parentId 41 | * @return array 42 | * @author Zura Sekhniashvili 43 | */ 44 | private static function convertCommentsIntoTree($comments, $parentId = null): array 45 | { 46 | $commentTree = []; 47 | 48 | foreach ($comments as $comment) { 49 | if ($comment->parent_id === $parentId) { 50 | // Find all comment which has parentId as $comment->id 51 | $children = self::convertCommentsIntoTree($comments, $comment->id); 52 | $comment->childComments = $children; 53 | $comment->numOfComments = collect($children)->sum('numOfComments') + count($children); 54 | 55 | $commentTree[] = new CommentResource($comment); 56 | } 57 | } 58 | 59 | return $commentTree; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/Http/Resources/UserResource.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function toArray(Request $request): array 17 | { 18 | return [ 19 | "id" => $this->id, 20 | "name" => $this->name, 21 | "email" => $this->email, 22 | "email_verified_at" => $this->email_verified_at, 23 | "created_at" => $this->created_at, 24 | "updated_at" => $this->updated_at, 25 | "username" => $this->username, 26 | 'pinned_post_id' => $this->pinned_post_id, 27 | "cover_url" => $this->cover_path ? Storage::url($this->cover_path) : null, 28 | "avatar_url" => $this->avatar_path ? Storage::url($this->avatar_path) : '/img/default_avatar.webp', 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Models/Comment.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 24 | } 25 | 26 | public function post(): BelongsTo 27 | { 28 | return $this->belongsTo(Post::class); 29 | } 30 | 31 | public function reactions(): MorphMany 32 | { 33 | return $this->morphMany(Reaction::class, 'object'); 34 | } 35 | 36 | public function comments(): HasMany 37 | { 38 | return $this->hasMany(self::class, 'parent_id'); 39 | } 40 | 41 | public function isOwner($userId) 42 | { 43 | return $this->user_id == $userId; 44 | } 45 | 46 | public static function getAllChildrenComments($comment): array 47 | { 48 | $comments = Comment::query()->where('post_id', $comment->post_id)->get(); 49 | $result = [$comment]; 50 | self::_getAllChildrenComments($comments, $comment->id, $result); 51 | 52 | return $result; 53 | } 54 | 55 | private static function _getAllChildrenComments($comments, $parentId, &$result = []): void 56 | { 57 | foreach ($comments as $comment) { 58 | if ($comment->parent_id === $parentId) { 59 | $result[] = $comment; 60 | // Find all comment which has parentId as $comment->id 61 | self::_getAllChildrenComments($comments, $comment->id, $result); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/Models/Follower.php: -------------------------------------------------------------------------------- 1 | generateSlugsFrom('name') 28 | ->saveSlugsTo('slug') 29 | ->doNotGenerateSlugsOnUpdate(); 30 | } 31 | 32 | public function currentUserGroup(): HasOne 33 | { 34 | return $this->hasOne(GroupUser::class)->where('user_id', Auth::id()); 35 | } 36 | 37 | public function isAdmin($userId): bool 38 | { 39 | return GroupUser::query() 40 | ->where('user_id', $userId) 41 | ->where('group_id', $this->id) 42 | ->where('role', GroupUserRole::ADMIN->value) 43 | ->exists(); 44 | } 45 | 46 | public function hasApprovedUser($userId): bool 47 | { 48 | return GroupUser::query() 49 | ->where('user_id', $userId) 50 | ->where('group_id', $this->id) 51 | ->where('status', GroupUserStatus::APPROVED->value) 52 | ->exists(); 53 | } 54 | 55 | public function isOwner($userId): bool 56 | { 57 | return $this->user_id == $userId; 58 | } 59 | 60 | public function adminUsers(): BelongsToMany 61 | { 62 | return $this->belongsToMany(User::class, 'group_users') 63 | ->wherePivot('role', GroupUserRole::ADMIN->value); 64 | } 65 | 66 | public function pendingUsers(): BelongsToMany 67 | { 68 | return $this->belongsToMany(User::class, 'group_users') 69 | ->wherePivot('status', GroupUserStatus::PENDING->value); 70 | } 71 | 72 | public function approvedUsers(): BelongsToMany 73 | { 74 | return $this->belongsToMany(User::class, 'group_users') 75 | ->wherePivot('status', GroupUserStatus::APPROVED->value); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/Models/GroupUser.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class, 'created_by'); 28 | } 29 | 30 | public function user(): BelongsTo 31 | { 32 | return $this->belongsTo(User::class); 33 | } 34 | 35 | public function group(): BelongsTo 36 | { 37 | return $this->belongsTo(Group::class); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Models/PostAttachment.php: -------------------------------------------------------------------------------- 1 | delete($model->path); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Models/Reaction.php: -------------------------------------------------------------------------------- 1 | morphTo(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | protected $fillable = [ 26 | 'name', 27 | 'username', 28 | 'email', 29 | 'password', 30 | 'cover_path', 31 | 'avatar_path', 32 | 'pinned_post_id' 33 | ]; 34 | 35 | /** 36 | * The attributes that should be hidden for serialization. 37 | * 38 | * @var array 39 | */ 40 | protected $hidden = [ 41 | 'password', 42 | 'remember_token', 43 | ]; 44 | 45 | /** 46 | * The attributes that should be cast. 47 | * 48 | * @var array 49 | */ 50 | protected $casts = [ 51 | 'email_verified_at' => 'datetime', 52 | 'password' => 'hashed', 53 | ]; 54 | 55 | public function getSlugOptions(): SlugOptions 56 | { 57 | return SlugOptions::create() 58 | ->generateSlugsFrom('name') 59 | ->saveSlugsTo('username') 60 | ->doNotGenerateSlugsOnUpdate(); 61 | } 62 | 63 | public function followers(): BelongsToMany 64 | { 65 | return $this->belongsToMany(User::class, 'followers', 'user_id', 'follower_id'); 66 | } 67 | 68 | public function followings(): BelongsToMany 69 | { 70 | return $this->belongsToMany(User::class, 'followers', 'follower_id', 'user_id'); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Notifications/CommentCreated.php: -------------------------------------------------------------------------------- 1 | 30 | */ 31 | public function via(object $notifiable): array 32 | { 33 | return ['mail']; 34 | } 35 | 36 | /** 37 | * Get the mail representation of the notification. 38 | */ 39 | public function toMail(object $notifiable): MailMessage 40 | { 41 | return ( new MailMessage ) 42 | // ->greeting('Hello My Friend') 43 | ->line('User "'.$this->comment->user->username.'" has made a comment on your post. Please see comment bellow.') 44 | ->line('"' . $this->comment->comment . '"') 45 | ->action('View Post', url(route('post.view', $this->post->id))) 46 | ->line('Thank you for using our application!') 47 | // ->salutation("My salutation") 48 | ; 49 | } 50 | 51 | /** 52 | * Get the array representation of the notification. 53 | * 54 | * @return array 55 | */ 56 | public function toArray(object $notifiable): array 57 | { 58 | return [ 59 | // 60 | ]; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/Notifications/CommentDeleted.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | public function via(object $notifiable): array 31 | { 32 | return ['mail']; 33 | } 34 | 35 | /** 36 | * Get the mail representation of the notification. 37 | */ 38 | public function toMail(object $notifiable): MailMessage 39 | { 40 | return (new MailMessage) 41 | ->line('You comment "'.Str::words($this->comment->comment, 5) 42 | .'" was removed on the post.') 43 | ->action('View Post', url(route('post.view', $this->post->id))) // TODO 44 | ->line('Thank you for using our application!'); 45 | } 46 | 47 | /** 48 | * Get the array representation of the notification. 49 | * 50 | * @return array 51 | */ 52 | public function toArray(object $notifiable): array 53 | { 54 | return [ 55 | // 56 | ]; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/Notifications/FollowUser.php: -------------------------------------------------------------------------------- 1 | 27 | */ 28 | public function via(object $notifiable): array 29 | { 30 | return ['mail']; 31 | } 32 | 33 | /** 34 | * Get the mail representation of the notification. 35 | */ 36 | public function toMail(object $notifiable): MailMessage 37 | { 38 | if ($this->follow) { 39 | $subject = 'User "' . $this->user->username . '" has followed you'; 40 | } else { 41 | $subject = 'User "' . $this->user->username . '" is no more following you'; 42 | } 43 | return ( new MailMessage ) 44 | ->subject($subject) 45 | ->line($subject) 46 | ->action('View Profile', url(route('profile', $this->user))) 47 | ->line('Thank you for using our application!'); 48 | } 49 | 50 | /** 51 | * Get the array representation of the notification. 52 | * 53 | * @return array 54 | */ 55 | public function toArray(object $notifiable): array 56 | { 57 | return [ 58 | // 59 | ]; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/Notifications/InvitationApproved.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | public function via(object $notifiable): array 31 | { 32 | return ['mail']; 33 | } 34 | 35 | /** 36 | * Get the mail representation of the notification. 37 | */ 38 | public function toMail(object $notifiable): MailMessage 39 | { 40 | return (new MailMessage) 41 | ->line('User "'.$this->user->name.'" has join to group "'.$this->group->name.'"') 42 | ->action('Open Group', url(route('group.profile', $this->group))) 43 | ->line('Thank you for using our application!'); 44 | } 45 | 46 | /** 47 | * Get the array representation of the notification. 48 | * 49 | * @return array 50 | */ 51 | public function toArray(object $notifiable): array 52 | { 53 | return [ 54 | // 55 | ]; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Notifications/InvitationInGroup.php: -------------------------------------------------------------------------------- 1 | 27 | */ 28 | public function via(object $notifiable): array 29 | { 30 | return ['mail']; 31 | } 32 | 33 | /** 34 | * Get the mail representation of the notification. 35 | */ 36 | public function toMail(object $notifiable): MailMessage 37 | { 38 | return ( new MailMessage ) 39 | ->line('You have been invited to join to group "' . $this->group->name . '"') 40 | ->action('Join the Group', url(route('group.approveInvitation', $this->token))) 41 | ->line('The link will be valid for next ' . $this->hours . ' hours'); 42 | } 43 | 44 | /** 45 | * Get the array representation of the notification. 46 | * 47 | * @return array 48 | */ 49 | public function toArray(object $notifiable): array 50 | { 51 | return [ 52 | // 53 | ]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Notifications/PostCreated.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | public function via(object $notifiable): array 31 | { 32 | return ['mail']; 33 | } 34 | 35 | /** 36 | * Get the mail representation of the notification. 37 | */ 38 | public function toMail(object $notifiable): MailMessage 39 | { 40 | return ( new MailMessage ) 41 | ->lineIf(!!$this->group, 'New post was added by user "' . $this->user->username . '" in group "' . $this->group?->slug . '".') 42 | ->lineIf(!$this->group, 'New post was added by user "' . $this->user->username . '"') 43 | ->action('View Post', url(route('post.view', $this->post->id))) 44 | ->line('Thank you for using our application!'); 45 | } 46 | 47 | /** 48 | * Get the array representation of the notification. 49 | * 50 | * @return array 51 | */ 52 | public function toArray(object $notifiable): array 53 | { 54 | return [ 55 | // 56 | ]; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/Notifications/PostDeleted.php: -------------------------------------------------------------------------------- 1 | 28 | */ 29 | public function via(object $notifiable): array 30 | { 31 | return ['mail']; 32 | } 33 | 34 | /** 35 | * Get the mail representation of the notification. 36 | */ 37 | public function toMail(object $notifiable): MailMessage 38 | { 39 | return (new MailMessage) 40 | ->line('Your post was deleted inside group "'.$this->group->name.'".') 41 | ->action('Open Group', url(route('group.profile', $this->group->slug))) 42 | ->line('Thank you for using our application!'); 43 | } 44 | 45 | /** 46 | * Get the array representation of the notification. 47 | * 48 | * @return array 49 | */ 50 | public function toArray(object $notifiable): array 51 | { 52 | return [ 53 | // 54 | ]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Notifications/ReactionAddedOnComment.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | public function via(object $notifiable): array 31 | { 32 | return ['mail']; 33 | } 34 | 35 | /** 36 | * Get the mail representation of the notification. 37 | */ 38 | public function toMail(object $notifiable): MailMessage 39 | { 40 | return ( new MailMessage ) 41 | ->line('User "' . $this->user->username . '" has liked your comment. Your comment: ') 42 | ->line('"'.$this->comment->comment.'"') 43 | ->action('View Post', url(route('post.view', $this->post->id))) 44 | ->line('Thank you for using our application!'); 45 | } 46 | 47 | /** 48 | * Get the array representation of the notification. 49 | * 50 | * @return array 51 | */ 52 | public function toArray(object $notifiable): array 53 | { 54 | return [ 55 | // 56 | ]; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/Notifications/ReactionAddedOnPost.php: -------------------------------------------------------------------------------- 1 | 28 | */ 29 | public function via(object $notifiable): array 30 | { 31 | return ['mail']; 32 | } 33 | 34 | /** 35 | * Get the mail representation of the notification. 36 | */ 37 | public function toMail(object $notifiable): MailMessage 38 | { 39 | return (new MailMessage) 40 | ->line('User "'.$this->user->username.'" liked your post.') 41 | ->action('View Post', url(route('post.view', $this->post->id))) 42 | ->line('Thank you for using our application!'); 43 | } 44 | 45 | /** 46 | * Get the array representation of the notification. 47 | * 48 | * @return array 49 | */ 50 | public function toArray(object $notifiable): array 51 | { 52 | return [ 53 | // 54 | ]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Notifications/RequestApproved.php: -------------------------------------------------------------------------------- 1 | 28 | */ 29 | public function via(object $notifiable): array 30 | { 31 | return ['mail']; 32 | } 33 | 34 | /** 35 | * Get the mail representation of the notification. 36 | */ 37 | public function toMail(object $notifiable): MailMessage 38 | { 39 | $action = ( $this->approved ? 'approved' : 'rejected' ); 40 | 41 | return ( new MailMessage ) 42 | ->subject('Request was ' . $action) 43 | ->line('Your request to join to group "' . $this->group->name . '" has been ' . $action) 44 | ->action('Open Group', url(route('group.profile', $this->group))) 45 | ->line('Thank you for using our application!'); 46 | } 47 | 48 | /** 49 | * Get the array representation of the notification. 50 | * 51 | * @return array 52 | */ 53 | public function toArray(object $notifiable): array 54 | { 55 | return [ 56 | // 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/Notifications/RequestToJoinGroup.php: -------------------------------------------------------------------------------- 1 | 28 | */ 29 | public function via(object $notifiable): array 30 | { 31 | return ['mail']; 32 | } 33 | 34 | /** 35 | * Get the mail representation of the notification. 36 | */ 37 | public function toMail(object $notifiable): MailMessage 38 | { 39 | return (new MailMessage) 40 | ->line('User "'.$this->user->name.'" requested to join to group "'.$this->group->name.'"') 41 | ->action('Approve Request', url(route('group.profile', $this->group))) 42 | ->line('Thank you for using our application!'); 43 | } 44 | 45 | /** 46 | * Get the array representation of the notification. 47 | * 48 | * @return array 49 | */ 50 | public function toArray(object $notifiable): array 51 | { 52 | return [ 53 | // 54 | ]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Notifications/RoleChanged.php: -------------------------------------------------------------------------------- 1 | 27 | */ 28 | public function via(object $notifiable): array 29 | { 30 | return ['mail']; 31 | } 32 | 33 | /** 34 | * Get the mail representation of the notification. 35 | */ 36 | public function toMail(object $notifiable): MailMessage 37 | { 38 | return (new MailMessage) 39 | ->line('Your role was changed into "'.$this->role.'" for group "'.$this->group->name.'".') 40 | ->action('Open Group', url(route('group.profile', $this->group))) 41 | ->line('Thank you for using our application!'); 42 | } 43 | 44 | /** 45 | * Get the array representation of the notification. 46 | * 47 | * @return array 48 | */ 49 | public function toArray(object $notifiable): array 50 | { 51 | return [ 52 | // 53 | ]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Notifications/UserRemovedFromGroup.php: -------------------------------------------------------------------------------- 1 | 27 | */ 28 | public function via(object $notifiable): array 29 | { 30 | return ['mail']; 31 | } 32 | 33 | /** 34 | * Get the mail representation of the notification. 35 | */ 36 | public function toMail(object $notifiable): MailMessage 37 | { 38 | return (new MailMessage) 39 | ->line('You have been removed from group "'.$this->group->name.'" by admin users.') 40 | ->action('Open Group', url(route('group.profile', $this->group->slug))) 41 | ->line('Thank you for using our application!'); 42 | } 43 | 44 | /** 45 | * Get the array representation of the notification. 46 | * 47 | * @return array 48 | */ 49 | public function toArray(object $notifiable): array 50 | { 51 | return [ 52 | // 53 | ]; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->environment('local')) { 16 | $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class); 17 | $this->app->register(TelescopeServiceProvider::class); 18 | } 19 | } 20 | 21 | /** 22 | * Bootstrap any application services. 23 | */ 24 | public function boot(): void 25 | { 26 | JsonResource::withoutWrapping(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | */ 26 | public function boot(): void 27 | { 28 | // 29 | } 30 | 31 | /** 32 | * Determine if events and listeners should be automatically discovered. 33 | */ 34 | public function shouldDiscoverEvents(): bool 35 | { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | by($request->user()?->id ?: $request->ip()); 29 | }); 30 | 31 | $this->routes(function () { 32 | Route::middleware('api') 33 | ->prefix('api') 34 | ->group(base_path('routes/api.php')); 35 | 36 | Route::middleware('web') 37 | ->group(base_path('routes/web.php')); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Providers/TelescopeServiceProvider.php: -------------------------------------------------------------------------------- 1 | hideSensitiveRequestDetails(); 20 | 21 | Telescope::filter(function (IncomingEntry $entry) { 22 | if ($this->app->environment('local')) { 23 | return true; 24 | } 25 | 26 | return $entry->isReportableException() || 27 | $entry->isFailedRequest() || 28 | $entry->isFailedJob() || 29 | $entry->isScheduledTask() || 30 | $entry->hasMonitoredTag(); 31 | }); 32 | } 33 | 34 | /** 35 | * Prevent sensitive request details from being logged by Telescope. 36 | */ 37 | protected function hideSensitiveRequestDetails(): void 38 | { 39 | if ($this->app->environment('local')) { 40 | return; 41 | } 42 | 43 | Telescope::hideRequestParameters(['_token']); 44 | 45 | Telescope::hideRequestHeaders([ 46 | 'cookie', 47 | 'x-csrf-token', 48 | 'x-xsrf-token', 49 | ]); 50 | } 51 | 52 | /** 53 | * Register the Telescope gate. 54 | * 55 | * This gate determines who can access Telescope in non-local environments. 56 | */ 57 | protected function gate(): void 58 | { 59 | Gate::define('viewTelescope', function ($user) { 60 | return in_array($user->email, [ 61 | // 62 | ]); 63 | }); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The skeleton application for the Laravel framework.", 5 | "keywords": ["laravel", "framework"], 6 | "license": "MIT", 7 | "require": { 8 | "ext-dom": "*", 9 | "php": "^8.1", 10 | "guzzlehttp/guzzle": "^7.8", 11 | "inertiajs/inertia-laravel": "^0.6.8", 12 | "laravel/framework": "^10.10", 13 | "laravel/sanctum": "^3.2", 14 | "laravel/tinker": "^2.8", 15 | "openai-php/laravel": "^0.8.1", 16 | "spatie/laravel-sluggable": "^3.5", 17 | "tightenco/ziggy": "^1.0" 18 | }, 19 | "require-dev": { 20 | "fakerphp/faker": "^1.9.1", 21 | "laravel/breeze": "^1.26", 22 | "laravel/pint": "^1.0", 23 | "laravel/sail": "^1.18", 24 | "laravel/telescope": "^4.17", 25 | "mockery/mockery": "^1.4.4", 26 | "nunomaduro/collision": "^7.0", 27 | "pestphp/pest": "^2.0", 28 | "pestphp/pest-plugin-laravel": "^2.0", 29 | "spatie/laravel-ignition": "^2.0" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "App\\": "app/", 34 | "Database\\Factories\\": "database/factories/", 35 | "Database\\Seeders\\": "database/seeders/" 36 | } 37 | }, 38 | "autoload-dev": { 39 | "psr-4": { 40 | "Tests\\": "tests/" 41 | } 42 | }, 43 | "scripts": { 44 | "post-autoload-dump": [ 45 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 46 | "@php artisan package:discover --ansi" 47 | ], 48 | "post-update-cmd": [ 49 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 50 | ], 51 | "post-root-package-install": [ 52 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 53 | ], 54 | "post-create-project-cmd": [ 55 | "@php artisan key:generate --ansi" 56 | ] 57 | }, 58 | "extra": { 59 | "laravel": { 60 | "dont-discover": [ 61 | "laravel/telescope" 62 | ] 63 | } 64 | }, 65 | "config": { 66 | "optimize-autoloader": true, 67 | "preferred-install": "dist", 68 | "sort-packages": true, 69 | "allow-plugins": { 70 | "pestphp/pest-plugin": true, 71 | "php-http/discovery": true 72 | } 73 | }, 74 | "minimum-stability": "stable", 75 | "prefer-stable": true 76 | } 77 | -------------------------------------------------------------------------------- /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 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 41 | 'port' => env('PUSHER_PORT', 443), 42 | 'scheme' => env('PUSHER_SCHEME', 'https'), 43 | 'encrypted' => true, 44 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 45 | ], 46 | 'client_options' => [ 47 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 48 | ], 49 | ], 50 | 51 | 'ably' => [ 52 | 'driver' => 'ably', 53 | 'key' => env('ABLY_KEY'), 54 | ], 55 | 56 | 'redis' => [ 57 | 'driver' => 'redis', 58 | 'connection' => 'default', 59 | ], 60 | 61 | 'log' => [ 62 | 'driver' => 'log', 63 | ], 64 | 65 | 'null' => [ 66 | 'driver' => 'null', 67 | ], 68 | 69 | ], 70 | 71 | ]; 72 | -------------------------------------------------------------------------------- /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_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been set up for each driver as an example of the required values. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 12), 33 | 'verify' => true, 34 | ], 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Argon Options 39 | |-------------------------------------------------------------------------- 40 | | 41 | | Here you may specify the configuration options that should be used when 42 | | passwords are hashed using the Argon algorithm. These will allow you 43 | | to control the amount of time it takes to hash the given password. 44 | | 45 | */ 46 | 47 | 'argon' => [ 48 | 'memory' => 65536, 49 | 'threads' => 1, 50 | 'time' => 4, 51 | 'verify' => true, 52 | ], 53 | 54 | ]; 55 | -------------------------------------------------------------------------------- /config/openai.php: -------------------------------------------------------------------------------- 1 | env('OPENAI_API_KEY'), 16 | 'organization' => env('OPENAI_ORGANIZATION'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Request Timeout 21 | |-------------------------------------------------------------------------- 22 | | 23 | | The timeout may be used to specify the maximum number of seconds to wait 24 | | for a response. By default, the client will time out after 30 seconds. 25 | */ 26 | 27 | 'request_timeout' => env('OPENAI_REQUEST_TIMEOUT', 30), 28 | ]; 29 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /config/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 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | protected static ?string $password; 15 | 16 | /** 17 | * Define the model's default state. 18 | * 19 | * @return array 20 | */ 21 | public function definition(): array 22 | { 23 | return [ 24 | 'name' => fake()->name(), 25 | 'email' => fake()->unique()->safeEmail(), 26 | 'email_verified_at' => now(), 27 | 'password' => static::$password ??= Hash::make('password'), 28 | 'remember_token' => Str::random(10), 29 | ]; 30 | } 31 | 32 | /** 33 | * Indicate that the model's email address should be unverified. 34 | */ 35 | public function unverified(): static 36 | { 37 | return $this->state(fn (array $attributes) => [ 38 | 'email_verified_at' => null, 39 | ]); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('users'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180010_create_groups_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name', 255); 17 | $table->string('slug', 255); 18 | $table->string('cover_path', 1024)->nullable(); 19 | $table->string('thumbnail_path', 1024)->nullable(); 20 | $table->boolean('auto_approval')->default(true); 21 | $table->text('about')->nullable(); 22 | $table->foreignId('user_id')->constrained('users'); 23 | $table->timestamp('deleted_at')->nullable(); 24 | $table->foreignId('deleted_by')->nullable()->constrained('users'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | */ 32 | public function down(): void 33 | { 34 | Schema::dropIfExists('groups'); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180012_create_group_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('status', 25); // approved, pending 17 | $table->string('role', 25); // admin, user 18 | $table->string('token', 1024)->nullable(); 19 | $table->timestamp('token_expire_date')->nullable(); 20 | $table->timestamp('token_used')->nullable(); 21 | $table->foreignId('user_id')->constrained('users'); 22 | $table->foreignId('group_id')->constrained('groups'); 23 | $table->foreignId('created_by')->constrained('users'); 24 | $table->timestamp('created_at')->nullable(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | */ 31 | public function down(): void 32 | { 33 | Schema::dropIfExists('group_users'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180014_create_posts_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->longText('body')->nullable(); 17 | $table->foreignId('user_id')->constrained('users'); 18 | $table->foreignId('group_id')->nullable()->constrained('groups'); 19 | $table->foreignId('deleted_by')->nullable()->constrained('users'); 20 | $table->timestamp('deleted_at')->nullable(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('posts'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180025_create_post_attachments_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('post_id')->constrained('posts'); 17 | $table->string('name', 255); // test.png 18 | $table->string('path', 255); // 19 | $table->string('mime', 25); // image/png 20 | $table->foreignId('created_by')->constrained('users'); 21 | $table->timestamp('created_at')->nullable(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('post_attachments'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180038_create_post_reactions_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('post_id')->constrained('posts'); 17 | $table->string('type'); // like, dislike, sad, laugh 18 | $table->foreignId('user_id')->constrained('users'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('post_reactions'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180053_create_comments_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('post_id')->constrained('posts'); 17 | $table->text('comment'); 18 | $table->foreignId('user_id')->constrained('users'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('comments'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_180124_create_followers_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('user_id')->constrained('users'); 17 | $table->foreignId('follower_id')->constrained('users'); 18 | $table->timestamp('created_at')->nullable(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | */ 25 | public function down(): void 26 | { 27 | Schema::dropIfExists('followers'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /database/migrations/2023_11_16_184001_add_columns_to_users_table.php: -------------------------------------------------------------------------------- 1 | string('username'); 16 | $table->string('cover_path', 1024)->nullable(); 17 | $table->string('avatar_path', 1024)->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::table('users', function (Blueprint $table) { 27 | $table->dropColumn('username'); 28 | $table->dropColumn('cover_path'); 29 | $table->dropColumn('avatar_path'); 30 | }); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2023_11_28_205441_add_size_column_to_post_attachments_table.php: -------------------------------------------------------------------------------- 1 | integer('size')->after('mime'); 15 | }); 16 | } 17 | 18 | /** 19 | * Reverse the migrations. 20 | */ 21 | public function down(): void 22 | { 23 | Schema::table('post_attachments', function (Blueprint $table) { 24 | $table->dropColumn('size'); 25 | }); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /database/migrations/2023_12_06_195921_change_post_reactions_table.php: -------------------------------------------------------------------------------- 1 | dropForeign(['post_id']); 16 | $table->renameColumn('post_id', 'object_id'); 17 | }); 18 | Schema::table('post_reactions', function (Blueprint $table) { 19 | $table->string('object_type')->after('object_id'); 20 | $table->rename('reactions'); 21 | }); 22 | 23 | DB::table('reactions') 24 | ->update(['object_type' => 'App\Models\Post']); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::table('reactions', function (Blueprint $table) { 33 | $table->rename('post_reactions'); 34 | }); 35 | Schema::table('post_reactions', function (Blueprint $table) { 36 | $table->dropColumn('object_type'); 37 | $table->renameColumn('object_id', 'post_id'); 38 | $table->foreign('post_id')->references('id')->on('posts'); 39 | }); 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /database/migrations/2023_12_06_210813_add_parent_id_to_comments.php: -------------------------------------------------------------------------------- 1 | bigInteger('parent_id')->unsigned()->nullable(); 16 | }); 17 | } 18 | 19 | /** 20 | * Reverse the migrations. 21 | */ 22 | public function down(): void 23 | { 24 | Schema::table('comments', function (Blueprint $table) { 25 | $table->dropColumn('parent_id'); 26 | }); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /database/migrations/2023_12_16_125648_add_preview_column_to_posts_table.php: -------------------------------------------------------------------------------- 1 | json('preview')->nullable(); 15 | $table->string('preview_url', 2000)->nullable(); 16 | }); 17 | } 18 | 19 | /** 20 | * Reverse the migrations. 21 | */ 22 | public function down(): void 23 | { 24 | Schema::table('posts', function (Blueprint $table) { 25 | $table->dropColumn('preview_url'); 26 | $table->dropColumn('preview'); 27 | }); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /database/migrations/2023_12_16_145941_add_pinned_post_id_column_to_groups_and_users_tables.php: -------------------------------------------------------------------------------- 1 | foreignId('pinned_post_id')->nullable()->constrained('posts'); 16 | }); 17 | 18 | Schema::table('users', function (Blueprint $table) { 19 | $table->foreignId('pinned_post_id')->nullable()->constrained('posts'); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::table('groups', function (Blueprint $table) { 29 | $table->dropColumn('pinned_post_id'); 30 | }); 31 | 32 | Schema::table('users', function (Blueprint $table) { 33 | $table->dropColumn('pinned_post_id'); 34 | }); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /database/migrations/2023_12_23_113538_add_foreign_key_on_comments_table_for_parent_id.php: -------------------------------------------------------------------------------- 1 | foreign('parent_id') 16 | ->references('id') 17 | ->on('comments') 18 | ->onDelete('cascade'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | */ 25 | public function down(): void 26 | { 27 | Schema::table('comments', function(Blueprint $table) { 28 | $table->dropForeign(['parent_id']); 29 | }); 30 | 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | 17 | // \App\Models\User::factory()->create([ 18 | // 'name' => 'Test User', 19 | // 'email' => 'test@example.com', 20 | // ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /docker/8.0/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | 6 | [opcache] 7 | opcache.enable_cli=1 8 | -------------------------------------------------------------------------------- /docker/8.0/start-container: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ ! -z "$WWWUSER" ]; then 4 | usermod -u $WWWUSER sail 5 | fi 6 | 7 | if [ ! -d /.composer ]; then 8 | mkdir /.composer 9 | fi 10 | 11 | chmod -R ugo+rw /.composer 12 | 13 | if [ $# -gt 0 ]; then 14 | exec gosu $WWWUSER "$@" 15 | else 16 | exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf 17 | fi 18 | -------------------------------------------------------------------------------- /docker/8.0/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/8.1/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | 6 | [opcache] 7 | opcache.enable_cli=1 8 | -------------------------------------------------------------------------------- /docker/8.1/start-container: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ ! -z "$WWWUSER" ]; then 4 | usermod -u $WWWUSER sail 5 | fi 6 | 7 | if [ ! -d /.composer ]; then 8 | mkdir /.composer 9 | fi 10 | 11 | chmod -R ugo+rw /.composer 12 | 13 | if [ $# -gt 0 ]; then 14 | exec gosu $WWWUSER "$@" 15 | else 16 | exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf 17 | fi 18 | -------------------------------------------------------------------------------- /docker/8.1/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/8.2/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 1G 3 | upload_max_filesize = 1G 4 | max_file_uploads = 50 5 | variables_order = EGPCS 6 | 7 | [opcache] 8 | opcache.enable_cli=1 9 | -------------------------------------------------------------------------------- /docker/8.2/start-container: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ ! -z "$WWWUSER" ]; then 4 | usermod -u $WWWUSER sail 5 | fi 6 | 7 | if [ ! -d /.composer ]; then 8 | mkdir /.composer 9 | fi 10 | 11 | chmod -R ugo+rw /.composer 12 | 13 | if [ $# -gt 0 ]; then 14 | exec gosu $WWWUSER "$@" 15 | else 16 | exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf 17 | fi 18 | -------------------------------------------------------------------------------- /docker/8.2/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/8.3/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | 6 | [opcache] 7 | opcache.enable_cli=1 8 | -------------------------------------------------------------------------------- /docker/8.3/start-container: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ ! -z "$WWWUSER" ]; then 4 | usermod -u $WWWUSER sail 5 | fi 6 | 7 | if [ ! -d /.composer ]; then 8 | mkdir /.composer 9 | fi 10 | 11 | chmod -R ugo+rw /.composer 12 | 13 | if [ $# -gt 0 ]; then 14 | exec gosu $WWWUSER "$@" 15 | else 16 | exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf 17 | fi 18 | -------------------------------------------------------------------------------- /docker/8.3/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/mysql/create-testing-database.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" <<-EOSQL 4 | CREATE DATABASE IF NOT EXISTS testing; 5 | GRANT ALL PRIVILEGES ON \`testing%\`.* TO '$MYSQL_USER'@'%'; 6 | EOSQL 7 | -------------------------------------------------------------------------------- /docker/pgsql/create-testing-database.sql: -------------------------------------------------------------------------------- 1 | SELECT 'CREATE DATABASE testing' 2 | WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'testing')\gexec 3 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/*": ["resources/js/*"] 6 | } 7 | }, 8 | "exclude": ["node_modules", "public"] 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build" 7 | }, 8 | "devDependencies": { 9 | "@inertiajs/vue3": "^1.0.0", 10 | "@tailwindcss/forms": "^0.5.3", 11 | "@vitejs/plugin-vue": "^4.0.0", 12 | "autoprefixer": "^10.4.12", 13 | "axios": "^1.6.2", 14 | "laravel-vite-plugin": "^0.8.0", 15 | "postcss": "^8.4.18", 16 | "tailwindcss": "^3.2.1", 17 | "vite": "^4.0.0", 18 | "vue": "^3.2.41" 19 | }, 20 | "dependencies": { 21 | "@ckeditor/ckeditor5-build-classic": "^40.1.0", 22 | "@ckeditor/ckeditor5-vue": "^5.1.0", 23 | "@headlessui/vue": "^1.7.16", 24 | "@heroicons/vue": "^2.0.18" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /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/thecodeholic/laravel-social-media-website/8abab19291fb1e142199a191a3b243fde4151ee4/public/favicon.ico -------------------------------------------------------------------------------- /public/img/default_avatar.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecodeholic/laravel-social-media-website/8abab19291fb1e142199a191a3b243fde4151ee4/public/img/default_avatar.webp -------------------------------------------------------------------------------- /public/img/default_cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecodeholic/laravel-social-media-website/8abab19291fb1e142199a191a3b243fde4151ee4/public/img/default_cover.jpg -------------------------------------------------------------------------------- /public/img/no_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecodeholic/laravel-social-media-website/8abab19291fb1e142199a191a3b243fde4151ee4/public/img/no_image.png -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/vendor/telescope/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thecodeholic/laravel-social-media-website/8abab19291fb1e142199a191a3b243fde4151ee4/public/vendor/telescope/favicon.ico -------------------------------------------------------------------------------- /public/vendor/telescope/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/app.js": "/app.js?id=140ed4bc5b10bc99492b97668c59272d", 3 | "/app-dark.css": "/app-dark.css?id=b11fa9a28e9d3aeb8c92986f319b3c44", 4 | "/app.css": "/app.css?id=b3ccfbe68f24cff776f83faa8dead721" 5 | } 6 | -------------------------------------------------------------------------------- /resources/js/Components/Checkbox.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 35 | -------------------------------------------------------------------------------- /resources/js/Components/DangerButton.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /resources/js/Components/Dropdown.vue: -------------------------------------------------------------------------------- 1 | 46 | 47 | 78 | -------------------------------------------------------------------------------- /resources/js/Components/DropdownLink.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 20 | -------------------------------------------------------------------------------- /resources/js/Components/InputError.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 16 | -------------------------------------------------------------------------------- /resources/js/Components/InputLabel.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 15 | -------------------------------------------------------------------------------- /resources/js/Components/InputTextarea.vue: -------------------------------------------------------------------------------- 1 | 50 | 51 | 60 | -------------------------------------------------------------------------------- /resources/js/Components/NavLink.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 27 | -------------------------------------------------------------------------------- /resources/js/Components/PrimaryButton.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 24 | -------------------------------------------------------------------------------- /resources/js/Components/ResponsiveNavLink.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 27 | -------------------------------------------------------------------------------- /resources/js/Components/SecondaryButton.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 18 | -------------------------------------------------------------------------------- /resources/js/Components/TextInput.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 34 | -------------------------------------------------------------------------------- /resources/js/Components/app/CreatePost.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 39 | 40 | 43 | -------------------------------------------------------------------------------- /resources/js/Components/app/FollowingList.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 37 | 38 | 41 | -------------------------------------------------------------------------------- /resources/js/Components/app/FollowingListItems.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 28 | 29 | 32 | -------------------------------------------------------------------------------- /resources/js/Components/app/GroupForm.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 43 | 44 | 47 | -------------------------------------------------------------------------------- /resources/js/Components/app/GroupItem.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 25 | 26 | 29 | -------------------------------------------------------------------------------- /resources/js/Components/app/GroupList.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 38 | 39 | 42 | -------------------------------------------------------------------------------- /resources/js/Components/app/GroupListItems.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 39 | 40 | 43 | -------------------------------------------------------------------------------- /resources/js/Components/app/GroupModal.vue: -------------------------------------------------------------------------------- 1 | 59 | 60 | 85 | 86 | -------------------------------------------------------------------------------- /resources/js/Components/app/IndigoButton.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 20 | 21 | 24 | -------------------------------------------------------------------------------- /resources/js/Components/app/PostAttachments.vue: -------------------------------------------------------------------------------- 1 | 14 | 55 | -------------------------------------------------------------------------------- /resources/js/Components/app/PostUserHeader.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 39 | 40 | 43 | -------------------------------------------------------------------------------- /resources/js/Components/app/ReadMoreReadLess.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 28 | 29 | 32 | -------------------------------------------------------------------------------- /resources/js/Components/app/UrlPreview.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 28 | 29 | 32 | -------------------------------------------------------------------------------- /resources/js/Components/app/UserListItem.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 60 | 61 | 64 | -------------------------------------------------------------------------------- /resources/js/Layouts/GuestLayout.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 21 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ConfirmPassword.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 51 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ForgotPassword.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 62 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/VerifyEmail.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 52 | -------------------------------------------------------------------------------- /resources/js/Pages/Error.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 20 | 21 | 24 | -------------------------------------------------------------------------------- /resources/js/Pages/Home.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 35 | 36 | 39 | -------------------------------------------------------------------------------- /resources/js/Pages/Post/View.vue: -------------------------------------------------------------------------------- 1 | 41 | 42 | 55 | 56 | 59 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Edit.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 35 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Partials/TabItem.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | 21 | 24 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/TabPhotos.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 57 | 58 | 61 | -------------------------------------------------------------------------------- /resources/js/Pages/Search.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 50 | 51 | 54 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | 3 | import {createApp, h} from 'vue'; 4 | import {createInertiaApp} from '@inertiajs/vue3'; 5 | import {resolvePageComponent} from 'laravel-vite-plugin/inertia-helpers'; 6 | import {ZiggyVue} from '../../vendor/tightenco/ziggy/dist/vue.m'; 7 | import CKEditor from '@ckeditor/ckeditor5-vue'; 8 | import '../css/app.css'; 9 | 10 | const html = window.document.documentElement 11 | const darkMode = parseInt(localStorage.getItem('darkMode') || 1) 12 | if (darkMode) { 13 | html.classList.add('dark') 14 | } else { 15 | html.classList.remove('dark') 16 | } 17 | 18 | const appName = import.meta.env.VITE_APP_NAME || 'Laravel'; 19 | 20 | createInertiaApp({ 21 | title: (title) => `${title} - ${appName}`, 22 | resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')), 23 | setup({el, App, props, plugin}) { 24 | return createApp({render: () => h(App, props)}) 25 | .use(plugin) 26 | .use(CKEditor) 27 | .use(ZiggyVue, Ziggy) 28 | .mount(el); 29 | }, 30 | progress: { 31 | color: '#4B5563', 32 | }, 33 | }); 34 | -------------------------------------------------------------------------------- /resources/js/axiosClient.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | 3 | const instance = axios.create(); 4 | // Add a request interceptor 5 | instance.interceptors.request.use(function (config) { 6 | // TODO 7 | return config; 8 | }); 9 | 10 | export default instance 11 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /resources/js/helpers.js: -------------------------------------------------------------------------------- 1 | export const isImage = (attachment) => { 2 | let mime = attachment.mime || attachment.type 3 | mime = mime.split('/') 4 | return mime[0].toLowerCase() === 'image' 5 | } 6 | 7 | export const isVideo = (attachment) => { 8 | let mime = attachment.mime || attachment.type 9 | mime = mime.split('/') 10 | return mime[0].toLowerCase() === 'video' 11 | } 12 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ config('app.name', 'Laravel') }} 8 | 9 | 10 | 11 | 12 | 13 | 14 | @routes 15 | @vite(['resources/js/app.js', "resources/js/Pages/{$page['component']}.vue"]) 16 | @inertiaHead 17 | 18 | 19 | @inertia 20 | 21 | 22 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /routes/auth.php: -------------------------------------------------------------------------------- 1 | group(function () { 15 | Route::get('register', [RegisteredUserController::class, 'create']) 16 | ->name('register'); 17 | 18 | Route::post('register', [RegisteredUserController::class, 'store']); 19 | 20 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 21 | ->name('login'); 22 | 23 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 24 | 25 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) 26 | ->name('password.request'); 27 | 28 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) 29 | ->name('password.email'); 30 | 31 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) 32 | ->name('password.reset'); 33 | 34 | Route::post('reset-password', [NewPasswordController::class, 'store']) 35 | ->name('password.store'); 36 | }); 37 | 38 | Route::middleware('auth')->group(function () { 39 | Route::get('verify-email', EmailVerificationPromptController::class) 40 | ->name('verification.notice'); 41 | 42 | Route::get('verify-email/{id}/{hash}', VerifyEmailController::class) 43 | ->middleware(['signed', 'throttle:6,1']) 44 | ->name('verification.verify'); 45 | 46 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) 47 | ->middleware('throttle:6,1') 48 | ->name('verification.send'); 49 | 50 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) 51 | ->name('password.confirm'); 52 | 53 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); 54 | 55 | Route::put('password', [PasswordController::class, 'update'])->name('password.update'); 56 | 57 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 58 | ->name('logout'); 59 | }); 60 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /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 | import defaultTheme from 'tailwindcss/defaultTheme'; 2 | import forms from '@tailwindcss/forms'; 3 | 4 | /** @type {import('tailwindcss').Config} */ 5 | export default { 6 | darkMode: 'class', 7 | content: [ 8 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', 9 | './storage/framework/views/*.php', 10 | './resources/views/**/*.blade.php', 11 | './resources/js/**/*.vue', 12 | ], 13 | 14 | theme: { 15 | extend: { 16 | fontFamily: { 17 | sans: ['Figtree', ...defaultTheme.fontFamily.sans], 18 | }, 19 | }, 20 | }, 21 | 22 | plugins: [forms], 23 | }; 24 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Feature/Auth/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get('/login'); 8 | 9 | $response->assertStatus(200); 10 | }); 11 | 12 | test('users can authenticate using the login screen', function () { 13 | $user = User::factory()->create(); 14 | 15 | $response = $this->post('/login', [ 16 | 'email' => $user->email, 17 | 'password' => 'password', 18 | ]); 19 | 20 | $this->assertAuthenticated(); 21 | $response->assertRedirect(RouteServiceProvider::HOME); 22 | }); 23 | 24 | test('users can not authenticate with invalid password', function () { 25 | $user = User::factory()->create(); 26 | 27 | $this->post('/login', [ 28 | 'email' => $user->email, 29 | 'password' => 'wrong-password', 30 | ]); 31 | 32 | $this->assertGuest(); 33 | }); 34 | 35 | test('users can logout', function () { 36 | $user = User::factory()->create(); 37 | 38 | $response = $this->actingAs($user)->post('/logout'); 39 | 40 | $this->assertGuest(); 41 | $response->assertRedirect('/'); 42 | }); 43 | -------------------------------------------------------------------------------- /tests/Feature/Auth/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | create([ 11 | 'email_verified_at' => null, 12 | ]); 13 | 14 | $response = $this->actingAs($user)->get('/verify-email'); 15 | 16 | $response->assertStatus(200); 17 | }); 18 | 19 | test('email can be verified', function () { 20 | $user = User::factory()->create([ 21 | 'email_verified_at' => null, 22 | ]); 23 | 24 | Event::fake(); 25 | 26 | $verificationUrl = URL::temporarySignedRoute( 27 | 'verification.verify', 28 | now()->addMinutes(60), 29 | ['id' => $user->id, 'hash' => sha1($user->email)] 30 | ); 31 | 32 | $response = $this->actingAs($user)->get($verificationUrl); 33 | 34 | Event::assertDispatched(Verified::class); 35 | expect($user->fresh()->hasVerifiedEmail())->toBeTrue(); 36 | $response->assertRedirect(RouteServiceProvider::HOME.'?verified=1'); 37 | }); 38 | 39 | test('email is not verified with invalid hash', function () { 40 | $user = User::factory()->create([ 41 | 'email_verified_at' => null, 42 | ]); 43 | 44 | $verificationUrl = URL::temporarySignedRoute( 45 | 'verification.verify', 46 | now()->addMinutes(60), 47 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 48 | ); 49 | 50 | $this->actingAs($user)->get($verificationUrl); 51 | 52 | expect($user->fresh()->hasVerifiedEmail())->toBeFalse(); 53 | }); 54 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordConfirmationTest.php: -------------------------------------------------------------------------------- 1 | create(); 7 | 8 | $response = $this->actingAs($user)->get('/confirm-password'); 9 | 10 | $response->assertStatus(200); 11 | }); 12 | 13 | test('password can be confirmed', function () { 14 | $user = User::factory()->create(); 15 | 16 | $response = $this->actingAs($user)->post('/confirm-password', [ 17 | 'password' => 'password', 18 | ]); 19 | 20 | $response->assertRedirect(); 21 | $response->assertSessionHasNoErrors(); 22 | }); 23 | 24 | test('password is not confirmed with invalid password', function () { 25 | $user = User::factory()->create(); 26 | 27 | $response = $this->actingAs($user)->post('/confirm-password', [ 28 | 'password' => 'wrong-password', 29 | ]); 30 | 31 | $response->assertSessionHasErrors(); 32 | }); 33 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | get('/forgot-password'); 9 | 10 | $response->assertStatus(200); 11 | }); 12 | 13 | test('reset password link can be requested', function () { 14 | Notification::fake(); 15 | 16 | $user = User::factory()->create(); 17 | 18 | $this->post('/forgot-password', ['email' => $user->email]); 19 | 20 | Notification::assertSentTo($user, ResetPassword::class); 21 | }); 22 | 23 | test('reset password screen can be rendered', function () { 24 | Notification::fake(); 25 | 26 | $user = User::factory()->create(); 27 | 28 | $this->post('/forgot-password', ['email' => $user->email]); 29 | 30 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) { 31 | $response = $this->get('/reset-password/'.$notification->token); 32 | 33 | $response->assertStatus(200); 34 | 35 | return true; 36 | }); 37 | }); 38 | 39 | test('password can be reset with valid token', function () { 40 | Notification::fake(); 41 | 42 | $user = User::factory()->create(); 43 | 44 | $this->post('/forgot-password', ['email' => $user->email]); 45 | 46 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { 47 | $response = $this->post('/reset-password', [ 48 | 'token' => $notification->token, 49 | 'email' => $user->email, 50 | 'password' => 'password', 51 | 'password_confirmation' => 'password', 52 | ]); 53 | 54 | $response->assertSessionHasNoErrors(); 55 | 56 | return true; 57 | }); 58 | }); 59 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordUpdateTest.php: -------------------------------------------------------------------------------- 1 | create(); 8 | 9 | $response = $this 10 | ->actingAs($user) 11 | ->from('/profile') 12 | ->put('/password', [ 13 | 'current_password' => 'password', 14 | 'password' => 'new-password', 15 | 'password_confirmation' => 'new-password', 16 | ]); 17 | 18 | $response 19 | ->assertSessionHasNoErrors() 20 | ->assertRedirect('/profile'); 21 | 22 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password)); 23 | }); 24 | 25 | test('correct password must be provided to update password', function () { 26 | $user = User::factory()->create(); 27 | 28 | $response = $this 29 | ->actingAs($user) 30 | ->from('/profile') 31 | ->put('/password', [ 32 | 'current_password' => 'wrong-password', 33 | 'password' => 'new-password', 34 | 'password_confirmation' => 'new-password', 35 | ]); 36 | 37 | $response 38 | ->assertSessionHasErrors('current_password') 39 | ->assertRedirect('/profile'); 40 | }); 41 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | get('/register'); 7 | 8 | $response->assertStatus(200); 9 | }); 10 | 11 | test('new users can register', function () { 12 | $response = $this->post('/register', [ 13 | 'name' => 'Test User', 14 | 'email' => 'test@example.com', 15 | 'password' => 'password', 16 | 'password_confirmation' => 'password', 17 | ]); 18 | 19 | $this->assertAuthenticated(); 20 | $response->assertRedirect(RouteServiceProvider::HOME); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 5 | 6 | $response->assertStatus(200); 7 | }); 8 | -------------------------------------------------------------------------------- /tests/Feature/ProfileTest.php: -------------------------------------------------------------------------------- 1 | create(); 7 | 8 | $response = $this 9 | ->actingAs($user) 10 | ->get('/profile'); 11 | 12 | $response->assertOk(); 13 | }); 14 | 15 | test('profile information can be updated', function () { 16 | $user = User::factory()->create(); 17 | 18 | $response = $this 19 | ->actingAs($user) 20 | ->patch('/profile', [ 21 | 'name' => 'Test User', 22 | 'email' => 'test@example.com', 23 | ]); 24 | 25 | $response 26 | ->assertSessionHasNoErrors() 27 | ->assertRedirect('/profile'); 28 | 29 | $user->refresh(); 30 | 31 | $this->assertSame('Test User', $user->name); 32 | $this->assertSame('test@example.com', $user->email); 33 | $this->assertNull($user->email_verified_at); 34 | }); 35 | 36 | test('email verification status is unchanged when the email address is unchanged', function () { 37 | $user = User::factory()->create(); 38 | 39 | $response = $this 40 | ->actingAs($user) 41 | ->patch('/profile', [ 42 | 'name' => 'Test User', 43 | 'email' => $user->email, 44 | ]); 45 | 46 | $response 47 | ->assertSessionHasNoErrors() 48 | ->assertRedirect('/profile'); 49 | 50 | $this->assertNotNull($user->refresh()->email_verified_at); 51 | }); 52 | 53 | test('user can delete their account', function () { 54 | $user = User::factory()->create(); 55 | 56 | $response = $this 57 | ->actingAs($user) 58 | ->delete('/profile', [ 59 | 'password' => 'password', 60 | ]); 61 | 62 | $response 63 | ->assertSessionHasNoErrors() 64 | ->assertRedirect('/'); 65 | 66 | $this->assertGuest(); 67 | $this->assertNull($user->fresh()); 68 | }); 69 | 70 | test('correct password must be provided to delete account', function () { 71 | $user = User::factory()->create(); 72 | 73 | $response = $this 74 | ->actingAs($user) 75 | ->from('/profile') 76 | ->delete('/profile', [ 77 | 'password' => 'wrong-password', 78 | ]); 79 | 80 | $response 81 | ->assertSessionHasErrors('password') 82 | ->assertRedirect('/profile'); 83 | 84 | $this->assertNotNull($user->fresh()); 85 | }); 86 | -------------------------------------------------------------------------------- /tests/Pest.php: -------------------------------------------------------------------------------- 1 | in('Feature'); 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Expectations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | When you're writing tests, you often need to check that values meet certain conditions. The 25 | | "expect()" function gives you access to a set of "expectations" methods that you can use 26 | | to assert different things. Of course, you may extend the Expectation API at any time. 27 | | 28 | */ 29 | 30 | expect()->extend('toBeOne', function () { 31 | return $this->toBe(1); 32 | }); 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Functions 37 | |-------------------------------------------------------------------------- 38 | | 39 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your 40 | | project that you don't want to repeat in every file. Here you can also expose helpers as 41 | | global functions to help you to reduce the number of lines of code in your test files. 42 | | 43 | */ 44 | 45 | function something() 46 | { 47 | // .. 48 | } 49 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import vue from '@vitejs/plugin-vue'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: 'resources/js/app.js', 9 | refresh: true, 10 | }), 11 | vue({ 12 | template: { 13 | transformAssetUrls: { 14 | base: null, 15 | includeAbsolute: false, 16 | }, 17 | }, 18 | }), 19 | ], 20 | }); 21 | --------------------------------------------------------------------------------