Repository: Lukabrazi111/voting-app Branch: master Commit: 5f67485e2d8e Files: 236 Total size: 5.1 MB Directory structure: gitextract_o66uexm6/ ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .styleci.yml ├── README.md ├── app/ │ ├── Console/ │ │ └── Kernel.php │ ├── Exceptions/ │ │ ├── DuplicateVoteException.php │ │ ├── Handler.php │ │ └── VoteNotFoundException.php │ ├── Http/ │ │ ├── Controllers/ │ │ │ ├── Auth/ │ │ │ │ ├── AuthenticatedSessionController.php │ │ │ │ ├── ConfirmablePasswordController.php │ │ │ │ ├── EmailVerificationNotificationController.php │ │ │ │ ├── EmailVerificationPromptController.php │ │ │ │ ├── NewPasswordController.php │ │ │ │ ├── PasswordResetLinkController.php │ │ │ │ ├── RegisteredUserController.php │ │ │ │ └── VerifyEmailController.php │ │ │ ├── CategoryController.php │ │ │ ├── CommentController.php │ │ │ ├── Controller.php │ │ │ ├── IdeaController.php │ │ │ ├── StatusController.php │ │ │ └── VoteController.php │ │ ├── Kernel.php │ │ ├── Livewire/ │ │ │ ├── AddComment.php │ │ │ ├── CommentNotifications.php │ │ │ ├── CreateIdea.php │ │ │ ├── DeleteComment.php │ │ │ ├── DeleteIdea.php │ │ │ ├── EditComment.php │ │ │ ├── EditIdea.php │ │ │ ├── IdeaComment.php │ │ │ ├── IdeaComments.php │ │ │ ├── IdeaIndex.php │ │ │ ├── IdeaShow.php │ │ │ ├── IdeasIndex.php │ │ │ ├── MarkCommentAsNotSpam.php │ │ │ ├── MarkCommentAsSpam.php │ │ │ ├── MarkIdeaAsNotSpam.php │ │ │ ├── MarkIdeaAsSpam.php │ │ │ ├── SetStatus.php │ │ │ └── StatusFilters.php │ │ ├── Middleware/ │ │ │ ├── Authenticate.php │ │ │ ├── EncryptCookies.php │ │ │ ├── PreventRequestsDuringMaintenance.php │ │ │ ├── RedirectIfAuthenticated.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustHosts.php │ │ │ ├── TrustProxies.php │ │ │ └── VerifyCsrfToken.php │ │ └── Requests/ │ │ ├── Auth/ │ │ │ └── LoginRequest.php │ │ ├── StoreCategoryRequest.php │ │ ├── StoreCommentRequest.php │ │ ├── StoreIdeaRequest.php │ │ ├── StoreStatusRequest.php │ │ ├── StoreVoteRequest.php │ │ ├── UpdateCategoryRequest.php │ │ ├── UpdateCommentRequest.php │ │ ├── UpdateIdeaRequest.php │ │ ├── UpdateStatusRequest.php │ │ └── UpdateVoteRequest.php │ ├── Jobs/ │ │ └── NotifyAllVoters.php │ ├── Mail/ │ │ └── IdeaStatusUpdatedMailable.php │ ├── Models/ │ │ ├── Category.php │ │ ├── Comment.php │ │ ├── Idea.php │ │ ├── Status.php │ │ ├── User.php │ │ └── Vote.php │ ├── Notifications/ │ │ └── CommentAdded.php │ ├── Policies/ │ │ ├── CategoryPolicy.php │ │ ├── CommentPolicy.php │ │ ├── IdeaPolicy.php │ │ ├── StatusPolicy.php │ │ └── VotePolicy.php │ ├── Providers/ │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ ├── HorizonServiceProvider.php │ │ └── RouteServiceProvider.php │ └── View/ │ └── Components/ │ ├── AppLayout.php │ └── GuestLayout.php ├── artisan ├── bootstrap/ │ ├── app.php │ └── cache/ │ └── .gitignore ├── composer.json ├── config/ │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── cors.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── horizon.php │ ├── logging.php │ ├── mail.php │ ├── queue.php │ ├── sanctum.php │ ├── services.php │ ├── session.php │ └── view.php ├── database/ │ ├── .gitignore │ ├── factories/ │ │ ├── CategoryFactory.php │ │ ├── CommentFactory.php │ │ ├── IdeaFactory.php │ │ ├── StatusFactory.php │ │ ├── UserFactory.php │ │ └── VoteFactory.php │ ├── migrations/ │ │ ├── 2014_10_12_000000_create_users_table.php │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ │ ├── 2021_11_19_154310_create_statuses_table.php │ │ ├── 2021_11_20_154310_create_categories_table.php │ │ ├── 2021_11_21_154310_create_ideas_table.php │ │ ├── 2021_11_24_195521_create_votes_table.php │ │ ├── 2021_12_19_130759_create_comments_table.php │ │ └── 2021_12_28_133951_create_notifications_table.php │ └── seeders/ │ ├── CategorySeeder.php │ ├── CommentSeeder.php │ ├── DatabaseSeeder.php │ ├── IdeaSeeder.php │ ├── StatusSeeder.php │ └── VoteSeeder.php ├── package.json ├── phpunit.xml ├── public/ │ ├── .htaccess │ ├── css/ │ │ └── app.css │ ├── index.php │ ├── js/ │ │ └── app.js │ ├── mix-manifest.json │ ├── robots.txt │ ├── vendor/ │ │ └── horizon/ │ │ ├── app-dark.css │ │ ├── app.css │ │ ├── app.js │ │ └── mix-manifest.json │ └── web.config ├── resources/ │ ├── css/ │ │ └── app.css │ ├── js/ │ │ ├── app.js │ │ └── bootstrap.js │ ├── lang/ │ │ └── en/ │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php │ └── views/ │ ├── auth/ │ │ ├── confirm-password.blade.php │ │ ├── forgot-password.blade.php │ │ ├── login.blade.php │ │ ├── register.blade.php │ │ ├── reset-password.blade.php │ │ └── verify-email.blade.php │ ├── components/ │ │ ├── application-logo.blade.php │ │ ├── auth-card.blade.php │ │ ├── auth-session-status.blade.php │ │ ├── auth-validation-errors.blade.php │ │ ├── button.blade.php │ │ ├── dropdown-link.blade.php │ │ ├── dropdown.blade.php │ │ ├── input.blade.php │ │ ├── label.blade.php │ │ ├── nav-link.blade.php │ │ ├── notification-success.blade.php │ │ └── responsive-nav-link.blade.php │ ├── dashboard.blade.php │ ├── emails/ │ │ ├── comment-added.blade.php │ │ ├── idea-status/ │ │ │ └── updated.blade.php │ │ └── idea-status-updated.blade.php │ ├── idea/ │ │ ├── index.blade.php │ │ └── show.blade.php │ ├── layouts/ │ │ ├── app.blade.php │ │ ├── guest.blade.php │ │ └── navigation.blade.php │ ├── livewire/ │ │ ├── add-comment.blade.php │ │ ├── comment-notifications.blade.php │ │ ├── create-idea.blade.php │ │ ├── delete-comment.blade.php │ │ ├── delete-idea.blade.php │ │ ├── edit-comment.blade.php │ │ ├── edit-idea.blade.php │ │ ├── idea-comment.blade.php │ │ ├── idea-comments.blade.php │ │ ├── idea-index.blade.php │ │ ├── idea-show.blade.php │ │ ├── ideas-index.blade.php │ │ ├── mark-comment-as-not-spam.blade.php │ │ ├── mark-comment-as-spam.blade.php │ │ ├── mark-idea-as-not-spam.blade.php │ │ ├── mark-idea-as-spam.blade.php │ │ ├── set-status.blade.php │ │ └── status-filters.blade.php │ └── welcome.blade.php ├── routes/ │ ├── api.php │ ├── auth.php │ ├── channels.php │ ├── console.php │ └── web.php ├── server.php ├── storage/ │ ├── app/ │ │ └── .gitignore │ ├── debugbar/ │ │ └── .gitignore │ ├── framework/ │ │ ├── .gitignore │ │ ├── cache/ │ │ │ └── .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 │ │ │ └── RegistrationTest.php │ │ ├── CategoryFiltersTest.php │ │ ├── Comments/ │ │ │ ├── AddCommentTest.php │ │ │ ├── DeleteCommentTest.php │ │ │ ├── EditCommentTest.php │ │ │ └── ShowCommentsTest.php │ │ ├── CreateIdeaTest.php │ │ ├── DeleteIdeaTest.php │ │ ├── EditIdeaTest.php │ │ ├── OtherFiltersTest.php │ │ ├── SearchFilterTest.php │ │ ├── ShowIdeasTest.php │ │ ├── SpamManagementTest.php │ │ ├── StatusFiltersTest.php │ │ ├── VoteIndexPageTest.php │ │ └── VoteShowPageTest.php │ ├── TestCase.php │ ├── Tests/ │ │ └── Feature/ │ │ └── AdminSetStatusTest.php │ └── Unit/ │ ├── GravatarTest.php │ ├── IdeaTest.php │ ├── Jobs/ │ │ └── NotifyAllVotersTest.php │ ├── StatusTest.php │ └── UserTest.php └── webpack.mix.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false [*.{yml,yaml}] indent_size = 2 [docker-compose.yml] indent_size = 4 ================================================ FILE: .gitattributes ================================================ * text=auto *.css linguist-vendored *.scss linguist-vendored *.js linguist-vendored CHANGELOG.md export-ignore ================================================ FILE: .gitignore ================================================ /node_modules /public/hot /public/storage /storage/*.key /vendor .env .env.backup .phpunit.result.cache docker-compose.override.yml Homestead.json Homestead.yaml npm-debug.log yarn-error.log /.idea /.vscode ================================================ FILE: .styleci.yml ================================================ php: preset: laravel version: 8 disabled: - no_unused_imports finder: not-name: - index.php - server.php js: finder: not-name: - webpack.mix.js css: true ================================================ FILE: README.md ================================================
## About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: - [Simple, fast routing engine](https://laravel.com/docs/routing). - [Powerful dependency injection container](https://laravel.com/docs/container). - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). - Database agnostic [schema migrations](https://laravel.com/docs/migrations). - [Robust background job processing](https://laravel.com/docs/queues). - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). Laravel is accessible, powerful, and provides tools required for large, robust applications. ## Learning Laravel Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. ## Laravel Sponsors We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). ### Premium Partners - **[Vehikl](https://vehikl.com/)** - **[Tighten Co.](https://tighten.co)** - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** - **[64 Robots](https://64robots.com)** - **[Cubet Techno Labs](https://cubettech.com)** - **[Cyber-Duck](https://cyber-duck.co.uk)** - **[Many](https://www.many.co.uk)** - **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** - **[DevSquad](https://devsquad.com)** - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** - **[OP.GG](https://op.gg)** - **[CMS Max](https://www.cmsmax.com/)** - **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** - **[Lendio](https://lendio.com)** - **[Romega Software](https://romegasoftware.com)** ## Contributing Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). ## Code of Conduct In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). ## Security Vulnerabilities If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. ## License The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). ================================================ FILE: app/Console/Kernel.php ================================================ command('inspire')->hourly(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } } ================================================ FILE: app/Exceptions/DuplicateVoteException.php ================================================ reportable(function (Throwable $e) { // }); } } ================================================ FILE: app/Exceptions/VoteNotFoundException.php ================================================ authenticate(); $request->session()->regenerate(); return redirect()->intended(RouteServiceProvider::HOME); } /** * Destroy an authenticated session. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function destroy(Request $request) { Auth::guard('web')->logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); return redirect('/'); } } ================================================ FILE: app/Http/Controllers/Auth/ConfirmablePasswordController.php ================================================ validate([ 'email' => $request->user()->email, 'password' => $request->password, ])) { throw ValidationException::withMessages([ 'password' => __('auth.password'), ]); } $request->session()->put('auth.password_confirmed_at', time()); return redirect()->intended(RouteServiceProvider::HOME); } } ================================================ FILE: app/Http/Controllers/Auth/EmailVerificationNotificationController.php ================================================ user()->hasVerifiedEmail()) { return redirect()->intended(RouteServiceProvider::HOME); } $request->user()->sendEmailVerificationNotification(); return back()->with('status', 'verification-link-sent'); } } ================================================ FILE: app/Http/Controllers/Auth/EmailVerificationPromptController.php ================================================ user()->hasVerifiedEmail() ? redirect()->intended(RouteServiceProvider::HOME) : view('auth.verify-email'); } } ================================================ FILE: app/Http/Controllers/Auth/NewPasswordController.php ================================================ $request]); } /** * Handle an incoming new password request. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException */ public function store(Request $request) { $request->validate([ 'token' => ['required'], 'email' => ['required', 'email'], 'password' => ['required', 'confirmed', Rules\Password::defaults()], ]); // Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $status = Password::reset( $request->only('email', 'password', 'password_confirmation', 'token'), function ($user) use ($request) { $user->forceFill([ 'password' => Hash::make($request->password), 'remember_token' => Str::random(60), ])->save(); event(new PasswordReset($user)); } ); // If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. return $status == Password::PASSWORD_RESET ? redirect()->route('login')->with('status', __($status)) : back()->withInput($request->only('email')) ->withErrors(['email' => __($status)]); } } ================================================ FILE: app/Http/Controllers/Auth/PasswordResetLinkController.php ================================================ validate([ 'email' => ['required', 'email'], ]); // We will send the password reset link to this user. Once we have attempted // to send the link, we will examine the response then see the message we // need to show to the user. Finally, we'll send out a proper response. $status = Password::sendResetLink( $request->only('email') ); return $status == Password::RESET_LINK_SENT ? back()->with('status', __($status)) : back()->withInput($request->only('email')) ->withErrors(['email' => __($status)]); } } ================================================ FILE: app/Http/Controllers/Auth/RegisteredUserController.php ================================================ validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'confirmed', Rules\Password::defaults()], ]); $user = User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => Hash::make($request->password), ]); event(new Registered($user)); Auth::login($user); return redirect(RouteServiceProvider::HOME); } } ================================================ FILE: app/Http/Controllers/Auth/VerifyEmailController.php ================================================ user()->hasVerifiedEmail()) { return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); } } ================================================ FILE: app/Http/Controllers/CategoryController.php ================================================ $idea, 'votesCount' => $idea->votes()->count(), 'backUrl' => url()->previous() !== url()->full() ? url()->previous() : route('idea.index'), ]); } /** * Show the form for editing the specified resource. * * @param Idea $idea * @return Response */ public function edit(Idea $idea) { // } /** * Update the specified resource in storage. * * @param UpdateIdeaRequest $request * @param Idea $idea * @return Response */ public function update(UpdateIdeaRequest $request, Idea $idea) { // } /** * Remove the specified resource from storage. * * @param Idea $idea * @return Response */ public function destroy(Idea $idea) { // } } ================================================ FILE: app/Http/Controllers/StatusController.php ================================================ [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; } ================================================ FILE: app/Http/Livewire/AddComment.php ================================================ 'required|min:4' ]; public function mount(Idea $idea) { $this->idea = $idea; } public function addComment() { if (auth()->guest()) { abort(Response::HTTP_FORBIDDEN); } $this->validate(); $newComment = Comment::create([ 'user_id' => auth()->id(), 'idea_id' => $this->idea->id, 'status_id' => 1, 'body' => $this->comment, ]); $this->reset('comment'); $this->idea->user->notify(new CommentAdded($newComment)); $this->emit('commentWasAdded', 'Comment was posted!'); } public function render() { return view('livewire.add-comment'); } } ================================================ FILE: app/Http/Livewire/CommentNotifications.php ================================================ notifications = collect([]); $this->isLoading = true; $this->getNotificationCount(); } public function getNotificationCount() { $this->notificationCount = auth()->user()->unreadNotifications()->count(); if ($this->notificationCount > self::NOTIFICATION_THRESHOLD) { $this->notificationCount = self::NOTIFICATION_THRESHOLD . '+'; } } public function markAsRead($notificationId) { if (auth()->guest()) { abort(Response::HTTP_FORBIDDEN); } $notification = DatabaseNotification::findOrFail($notificationId); $notification->markAsRead(); $comment = Comment::find($notification->data['comment_id']); session()->flash('scrollToComment', $comment->id); return redirect()->route('idea.show', [ 'idea' => $notification->data['idea_slug'], ]); } public function markAllAsRead() { if (auth()->guest()) { abort(Response::HTTP_FORBIDDEN); } auth()->user()->unreadNotifications()->markAsRead(); $this->getNotifications(); } public function getNotifications() { sleep(2); $this->notifications = auth()->user()->unreadNotifications->latest()->take(self::NOTIFICATION_THRESHOLD)->get(); $this->isLoading = false; } public function render() { return view('livewire.comment-notifications'); } } ================================================ FILE: app/Http/Livewire/CreateIdea.php ================================================ 'required|min:4', 'category' => 'required|integer|exists:categories,id', 'description' => 'required|min:4', ]; public function createIdea() { if (auth()->check()) { $this->validate(); Idea::create([ 'user_id' => auth()->id(), 'category_id' => $this->category, 'status_id' => 1, 'title' => $this->title, 'description' => $this->description, ]); session()->flash('success_message', 'Idea was added successfully!'); $this->reset(); return redirect()->route('idea.index'); } abort(Response::HTTP_FORBIDDEN); } public function render() { return view('livewire.create-idea', [ 'categories' => Category::all(), ]); } } ================================================ FILE: app/Http/Livewire/DeleteComment.php ================================================ comment = Comment::findOrFail($commentId); $this->emit('deleteCommentWasSet'); } public function deleteComment() { if (auth()->guest() || auth()->user()->cannot('delete', $this->comment)) { abort(Response::HTTP_FORBIDDEN); } Comment::destroy($this->comment->id); $this->comment = null; $this->emit('commentWasDeleted', 'Comment was deleted!'); } public function render() { return view('livewire.delete-comment'); } } ================================================ FILE: app/Http/Livewire/DeleteIdea.php ================================================ idea = $idea; } public function deleteIdea() { if (auth()->guest() || auth()->user()->cannot('delete', $this->idea)) { abort(Response::HTTP_FORBIDDEN); } Vote::where('idea_id', $this->idea->id)->delete(); Comment::where('idea_id', $this->idea->id)->delete(); Idea::destroy($this->idea->id); session()->flash('success_message', 'Idea was deleted successfully!'); return redirect(route('idea.index')); } public function render() { return view('livewire.delete-idea'); } } ================================================ FILE: app/Http/Livewire/EditComment.php ================================================ 'required|min:4', ]; protected $listeners = ['setEditComment']; public function setEditComment($commentId) { $this->comment = Comment::findOrFail($commentId); $this->body = $this->comment->body; $this->emit('editCommentWasSet'); } public function updateComment() { if (auth()->guest() || auth()->user()->cannot('update', $this->comment)) { abort(Response::HTTP_FORBIDDEN); } $this->validate(); $this->comment->body = $this->body; $this->comment->save(); $this->emit('commentWasUpdated', 'Comment was updated!'); } public function render() { return view('livewire.edit-comment'); } } ================================================ FILE: app/Http/Livewire/EditIdea.php ================================================ 'required|min:4', 'category' => 'required|integer|exists:categories,id', 'description' => 'required|min:4', ]; public function mount(Idea $idea) { $this->idea = $idea; $this->title = $idea->title; $this->category = $idea->category_id; $this->description = $idea->description; } public function updateIdea() { if (auth()->guest() || auth()->user()->cannot('update', $this->idea)) { abort(Response::HTTP_FORBIDDEN); } $this->validate(); $this->idea->update([ 'title' => $this->title, 'category_id' => $this->category, 'description' => $this->description, ]); $this->emit('ideaWasUpdated', 'Idea was updated successfully!'); } public function render() { return view('livewire.edit-idea', [ 'categories' => Category::all(), ]); } } ================================================ FILE: app/Http/Livewire/IdeaComment.php ================================================ comment->refresh(); } public function commentWasMarkedAsSpam() { $this->comment->refresh(); } public function commentWasMarkedAsNotSpam() { $this->comment->refresh(); } public function mount(Comment $comment, $ideaUserId) { $this->comment = $comment; $this->ideaUserId = $ideaUserId; } public function render() { return view('livewire.idea-comment'); } } ================================================ FILE: app/Http/Livewire/IdeaComments.php ================================================ idea->refresh(); $this->gotoPage($this->idea->comments()->paginate()->lastPage()); } public function statusWasUpdated() { $this->idea->refresh(); $this->gotoPage($this->idea->comments()->paginate()->lastPage()); } public function commentWasDeleted() { $this->idea->refresh(); $this->gotoPage(1); } public function mount(Idea $idea) { $this->idea = $idea; } public function render() { return view('livewire.idea-comments', [ 'comments' => Comment::with('user')->where('idea_id', $this->idea->id)->paginate()->withQueryString(), ]); } } ================================================ FILE: app/Http/Livewire/IdeaIndex.php ================================================ idea = $idea; $this->votesCount = $votesCount; $this->hasVoted = $idea->voted_by_user; } public function vote() { if (!auth()->check()) { return redirect(route('login')); } if ($this->hasVoted) { try { $this->idea->removeVote(auth()->user()); } catch (VoteNotFoundException $e) { // do nothing } $this->votesCount--; $this->hasVoted = false; } else { try { $this->idea->vote(auth()->user()); } catch (DuplicateVoteException $e) { // do nothing } $this->votesCount++; $this->hasVoted = true; } } public function render() { return view('livewire.idea-index'); } } ================================================ FILE: app/Http/Livewire/IdeaShow.php ================================================ idea = $idea; $this->votesCount = $votesCount; $this->hasVoted = $idea->isVotedByUser(auth()->user()); } public function vote() { if (!auth()->check()) { return redirect(route('login')); } if ($this->hasVoted) { try { $this->idea->removeVote(auth()->user()); } catch (VoteNotFoundException $e) { // do nothing } $this->votesCount--; $this->hasVoted = false; } else { try { $this->idea->vote(auth()->user()); } catch (DuplicateVoteException $e) { // do nothing } $this->votesCount++; $this->hasVoted = true; } } public function statusWasUpdated() { $this->idea->refresh(); } public function ideaWasUpdated() { $this->idea->refresh(); } public function ideaWasMarkedAsSpam() { $this->idea->refresh(); } public function ideaWasMarkedAsNotSpam() { $this->idea->refresh(); } public function commentWasAdded() { $this->idea->refresh(); } public function commentWasDeleted() { $this->idea->refresh(); } public function render() { return view('livewire.idea-show'); } } ================================================ FILE: app/Http/Livewire/IdeasIndex.php ================================================ status = request()->status ?? 'All'; } public function updatedFilter() { $this->resetPage(); if ($this->filter === 'My Ideas') { if (!auth()->check()) { return redirect()->route('login'); } } } public function updatingSearch() { $this->resetPage(); } public function queryStringUpdatedStatus($newStatus) { $this->resetPage(); $this->status = $newStatus; } public function render() { $statuses = Status::all()->pluck('id', 'name'); $categories = Category::all(); return view('livewire.ideas-index', [ 'ideas' => Idea::with('user', 'category', 'status') ->when($this->status && $this->status !== 'All', function ($query) use ($statuses) { return $query->where('status_id', $statuses->get($this->status)); })->when($this->category && $this->category !== 'All Categories', function ($query) use ($categories) { return $query->where('category_id', $categories->pluck('id', 'name')->get($this->category)); })->when($this->filter && $this->filter === 'Top Voted', function ($query) { return $query->orderByDesc('votes_count'); })->when($this->filter && $this->filter === 'My Ideas', function ($query) { return $query->where('user_id', auth()->id()); })->when($this->filter && $this->filter === 'Spam Ideas', function ($query) { return $query->where('spam_reports', '>', 0)->orderByDesc('spam_reports'); })->when($this->filter && $this->filter === 'Spam Comments', function ($query) { return $query->whereHas('comments', function ($query) { $query->where('spam_reports', '>', 0); }); })->when(strlen($this->search) >= 3, function ($query) { return $query->where('title', 'like', '%' . $this->search . '%'); }) ->addSelect(['voted_by_user' => Vote::select('id') ->where('user_id', auth()->id()) ->whereColumn('idea_id', 'ideas.id') ]) ->withCount('votes') ->withCount('comments') ->orderBy('id', 'desc') ->simplePaginate() ->withQueryString(), 'categories' => $categories, ]); } } ================================================ FILE: app/Http/Livewire/MarkCommentAsNotSpam.php ================================================ comment = Comment::findOrFail($commentId); $this->emit('markAsNotSpamCommentWasSet'); } public function markAsNotSpam() { if (auth()->guest()) { abort(Response::HTTP_FORBIDDEN); } $this->comment->spam_reports = 0; $this->comment->save(); $this->emit('commentWasMarkedAsNotSpam', 'Comment spam counter was reset!'); } public function render() { return view('livewire.mark-comment-as-not-spam'); } } ================================================ FILE: app/Http/Livewire/MarkCommentAsSpam.php ================================================ comment = Comment::findOrFail($commentId); $this->emit('markAsSpamCommentWasSet'); } public function markAsSpam() { if (auth()->guest()) { abort(Response::HTTP_FORBIDDEN); } $this->comment->spam_reports++; $this->comment->save(); $this->emit('commentWasMarkedAsSpam', 'Comment was marked as spam!'); } public function render() { return view('livewire.mark-comment-as-spam'); } } ================================================ FILE: app/Http/Livewire/MarkIdeaAsNotSpam.php ================================================ idea = $idea; } public function markAsNotSpam() { if (auth()->guest() || ! auth()->user()->isAdmin()) { abort(Response::HTTP_FORBIDDEN); } $this->idea->spam_reports = 0; $this->idea->save(); $this->emit('ideaWasMarkedAsNotSpam', 'Spam counter was reset!'); } public function render() { return view('livewire.mark-idea-as-not-spam'); } } ================================================ FILE: app/Http/Livewire/MarkIdeaAsSpam.php ================================================ idea = $idea; } public function markAsSpam() { if (auth()->guest()) { abort(Response::HTTP_FORBIDDEN); } $this->idea->spam_reports++; $this->idea->save(); $this->emit('ideaWasMarkedAsSpam', 'Idea was marked as spam!'); } public function render() { return view('livewire.mark-idea-as-spam'); } } ================================================ FILE: app/Http/Livewire/SetStatus.php ================================================ idea = $idea; $this->status = $idea->status_id; } public function setStatus() { if (!auth()->check() || !auth()->user()->isAdmin()) { abort(Response::HTTP_FORBIDDEN); } $this->idea->status_id = $this->status; $this->idea->save(); if ($this->notifyAllVoters) { NotifyAllVoters::dispatch($this->idea); } Comment::create([ 'user_id' => auth()->id(), 'idea_id' => $this->idea->id, 'status_id' => 1, 'body' => $this->comment ? $this->comment : 'No comment was added!', 'is_status_update' => true, ]); $this->reset('comment'); $this->emit('statusWasUpdated'); } public function render() { return view('livewire.set-status'); } } ================================================ FILE: app/Http/Livewire/StatusFilters.php ================================================ statusCount = Status::getCount(); $this->status = request()->status ?? 'All'; if (Route::currentRouteName() === 'idea.show') { $this->status = null; } } public function setStatus($newStatus) { $this->status = $newStatus; $this->emit('queryStringUpdatedStatus', $this->status); if ($this->getPreviousRouteName() === 'idea.show') { return redirect()->route('idea.index', [ 'status' => $this->status, ]); } } // private method private function getPreviousRouteName() { return app('router')->getRoutes()->match(app('request')->create(url()->previous()))->getName(); } public function render() { return view('livewire.status-filters'); } } ================================================ FILE: app/Http/Middleware/Authenticate.php ================================================ expectsJson()) { return route('login'); } } } ================================================ FILE: app/Http/Middleware/EncryptCookies.php ================================================ check()) { return redirect(RouteServiceProvider::HOME); } } return $next($request); } } ================================================ FILE: app/Http/Middleware/TrimStrings.php ================================================ allSubdomainsOfApplicationUrl(), ]; } } ================================================ FILE: app/Http/Middleware/TrustProxies.php ================================================ ['required', 'string', 'email'], 'password' => ['required', 'string'], ]; } /** * Attempt to authenticate the request's credentials. * * @return void * * @throws \Illuminate\Validation\ValidationException */ public function authenticate() { $this->ensureIsNotRateLimited(); if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ 'email' => __('auth.failed'), ]); } RateLimiter::clear($this->throttleKey()); } /** * Ensure the login request is not rate limited. * * @return void * * @throws \Illuminate\Validation\ValidationException */ public function ensureIsNotRateLimited() { if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } event(new Lockout($this)); $seconds = RateLimiter::availableIn($this->throttleKey()); throw ValidationException::withMessages([ 'email' => trans('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ]), ]); } /** * Get the rate limiting throttle key for the request. * * @return string */ public function throttleKey() { return Str::lower($this->input('email')).'|'.$this->ip(); } } ================================================ FILE: app/Http/Requests/StoreCategoryRequest.php ================================================ idea = $idea; } /** * Execute the job. * * @return void */ public function handle() { $this->idea->votes() ->select('name', 'email') ->chunk(100, function ($voters) { foreach ($voters as $user) { Mail::to($user) ->queue(new IdeaStatusUpdatedMailable($this->idea)); } }); } } ================================================ FILE: app/Mail/IdeaStatusUpdatedMailable.php ================================================ idea = $idea; } /** * Build the message. * * @return $this */ public function build() { return $this->subject('An idea you voted for has a new status') ->markdown('emails.idea-status-updated'); } } ================================================ FILE: app/Models/Category.php ================================================ hasMany(Idea::class); } } ================================================ FILE: app/Models/Comment.php ================================================ belongsTo(User::class); } public function idea() { return $this->belongsTo(Idea::class); } public function status() { return $this->belongsTo(Status::class); } } ================================================ FILE: app/Models/Idea.php ================================================ hasMany(Comment::class); } /** * Return the sluggable configuration array for this model. * * @return array */ public function sluggable(): array { return [ 'slug' => [ 'source' => 'title' ] ]; } public function user() { return $this->belongsTo(User::class); } public function category() { return $this->belongsTo(Category::class); } public function status() { return $this->belongsTo(Status::class); } public function votes() { return $this->belongsToMany(User::class, 'votes'); } public function isVotedByUser(?User $user) { if (!$user) { return false; } return Vote::where('user_id', $user->id)->where('idea_id', $this->id)->exists(); } public function vote(User $user) { if($this->isVotedByUser($user)) { throw new DuplicateVoteException; } Vote::create([ 'idea_id' => $this->id, 'user_id' => $user->id, ]); } public function removeVote(User $user) { $voteToDelete = Vote::where('idea_id', $this->id) ->where('user_id', $user->id) ->first(); if ($voteToDelete) { $voteToDelete->delete(); } else { throw new VoteNotFoundException(); } } } ================================================ FILE: app/Models/Status.php ================================================ hasMany(Idea::class); } public static function getCount() { return Idea::query() ->selectRaw("count(*) as all_statuses") ->selectRaw("count(case when status_id = 1 then 1 end) as open") ->selectRaw("count(case when status_id = 2 then 1 end) as considering") ->selectRaw("count(case when status_id = 3 then 1 end) as in_progress") ->selectRaw("count(case when status_id = 4 then 1 end) as implemented") ->selectRaw("count(case when status_id = 5 then 1 end) as closed") ->first() ->toArray(); } } ================================================ FILE: app/Models/User.php ================================================ 'datetime', ]; public function ideas() { return $this->hasMany(Idea::class); } public function votes() { return $this->belongsToMany(Idea::class, 'votes'); } public function comments() { return $this->hasMany(Comment::class); } public function getAvatar() { $firstCharacter = $this->email[0]; if (is_numeric($firstCharacter)) { $integerToUse = ord(strtolower($firstCharacter)) - 21; } else { $integerToUse = ord(strtolower($firstCharacter)) - 96; } return 'https://www.gravatar.com/avatar/' . md5($this->email) . '?s=200' . '&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-' . $integerToUse . '.png'; } public function isAdmin() { return in_array($this->email, [ 'jeffrey@laracasts.com', 'andre_madaran@hotmail.com', 'andrian@laracasts.com', 'lukakhangoshvili@gmail.com', 'lukabrazi@redberry.ge', ]); } } ================================================ FILE: app/Models/Vote.php ================================================ comment = $comment; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return ['database']; } /** * Get the mail representation of the notification. * * @param mixed $notifiable * @return MailMessage */ public function toMail($notifiable) { return (new MailMessage) ->subject('Laracasts Voting: A comment was posted on your idea') ->markdown('emails.comment-added', [ 'comment' => $this->comment, ]); } /** * Get the array representation of the notification. * * @param mixed $notifiable * @return array */ public function toArray($notifiable) { return [ 'comment_id' => $this->comment->id, 'comment_body' => $this->comment->body, 'user_avatar' => $this->comment->user->getAvatar(), 'user_name' => $this->comment->user->name, 'idea_id' => $this->comment->idea->id, 'idea_slug' => $this->comment->idea->slug, 'idea_title' => $this->comment->idea->title, ]; } } ================================================ FILE: app/Policies/CategoryPolicy.php ================================================ id === (int) $comment->user_id; } /** * Determine whether the user can delete the model. * * @param \App\Models\User $user * @param \App\Models\Comment $comment * @return \Illuminate\Auth\Access\Response|bool */ public function delete(User $user, Comment $comment) { return $user->id === (int) $comment->user_id || $user->isAdmin(); } /** * Determine whether the user can restore the model. * * @param \App\Models\User $user * @param \App\Models\Comment $comment * @return \Illuminate\Auth\Access\Response|bool */ public function restore(User $user, Comment $comment) { // } /** * Determine whether the user can permanently delete the model. * * @param \App\Models\User $user * @param \App\Models\Comment $comment * @return \Illuminate\Auth\Access\Response|bool */ public function forceDelete(User $user, Comment $comment) { // } } ================================================ FILE: app/Policies/IdeaPolicy.php ================================================ id === (int) $idea->user_id && now()->subHour() <= $idea->created_at; } /** * Determine whether the user can delete the model. * * @param \App\Models\User $user * @param \App\Models\Idea $idea * @return \Illuminate\Auth\Access\Response|bool */ public function delete(User $user, Idea $idea) { return $user->id === (int) $idea->user_id || $user->isAdmin(); } /** * Determine whether the user can restore the model. * * @param \App\Models\User $user * @param \App\Models\Idea $idea * @return \Illuminate\Auth\Access\Response|bool */ public function restore(User $user, Idea $idea) { // } /** * Determine whether the user can permanently delete the model. * * @param \App\Models\User $user * @param \App\Models\Idea $idea * @return \Illuminate\Auth\Access\Response|bool */ public function forceDelete(User $user, Idea $idea) { // } } ================================================ FILE: app/Policies/StatusPolicy.php ================================================ check() && auth()->user()->isAdmin(); }); } } ================================================ FILE: app/Providers/AuthServiceProvider.php ================================================ 'App\Policies\ModelPolicy', ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); // } } ================================================ FILE: app/Providers/BroadcastServiceProvider.php ================================================ [ SendEmailVerificationNotification::class, ], ]; /** * Register any events for your application. * * @return void */ public function boot() { // } } ================================================ FILE: app/Providers/HorizonServiceProvider.php ================================================ email, [ 'jeffrey@laracasts.com', 'andre_madaran@hotmail.com', 'andrian@laracasts.com', 'lukakhangoshvili@gmail.com' ]); }); } } ================================================ FILE: app/Providers/RouteServiceProvider.php ================================================ configureRateLimiting(); $this->routes(function () { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); }); } /** * Configure the rate limiters for the application. * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); }); } } ================================================ FILE: app/View/Components/AppLayout.php ================================================ make(Illuminate\Contracts\Console\Kernel::class); $status = $kernel->handle( $input = new Symfony\Component\Console\Input\ArgvInput, new Symfony\Component\Console\Output\ConsoleOutput ); /* |-------------------------------------------------------------------------- | Shutdown The Application |-------------------------------------------------------------------------- | | Once Artisan has finished running, we will fire off the shutdown events | so that any final work may be done by the application before we shut | down the process. This is the last thing to happen to the request. | */ $kernel->terminate($input, $status); exit($status); ================================================ FILE: bootstrap/app.php ================================================ singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class ); $app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class ); /* |-------------------------------------------------------------------------- | Return The Application |-------------------------------------------------------------------------- | | This script returns the application instance. The instance is given to | the calling script so we can separate the building of the instances | from the actual running of the application and sending responses. | */ return $app; ================================================ FILE: bootstrap/cache/.gitignore ================================================ * !.gitignore ================================================ FILE: composer.json ================================================ { "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "php": "^7.3|^8.0", "cviebrock/eloquent-sluggable": "^8.0", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.65", "laravel/horizon": "^5.7", "laravel/sanctum": "^2.11", "laravel/tinker": "^2.5", "livewire/livewire": "^2.7" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.6", "brianium/paratest": "^6.3", "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", "laravel/breeze": "^1.4", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^5.10", "phpunit/phpunit": "^9.5.10" }, "autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true } ================================================ FILE: config/app.php ================================================ env('APP_NAME', 'Laravel'), /* |-------------------------------------------------------------------------- | Application Environment |-------------------------------------------------------------------------- | | This value determines the "environment" your application is currently | running in. This may determine how you prefer to configure various | services the application utilizes. Set this in your ".env" file. | */ 'env' => env('APP_ENV', 'production'), /* |-------------------------------------------------------------------------- | Application Debug Mode |-------------------------------------------------------------------------- | | When your application is in debug mode, detailed error messages with | stack traces will be shown on every error that occurs within your | application. If disabled, a simple generic error page is shown. | */ 'debug' => (bool) env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- | Application URL |-------------------------------------------------------------------------- | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of | your application so that it is used when running Artisan tasks. | */ 'url' => env('APP_URL', 'http://localhost'), 'asset_url' => env('ASSET_URL', null), /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which | will be used by the PHP date and date-time functions. We have gone | ahead and set this to a sensible default for you out of the box. | */ 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | */ 'locale' => 'en', /* |-------------------------------------------------------------------------- | Application Fallback Locale |-------------------------------------------------------------------------- | | The fallback locale determines the locale to use when the current one | is not available. You may change the value to correspond to any of | the language folders that are provided through your application. | */ 'fallback_locale' => 'en', /* |-------------------------------------------------------------------------- | Faker Locale |-------------------------------------------------------------------------- | | This locale will be used by the Faker PHP library when generating fake | data for your database seeds. For example, this will be used to get | localized telephone numbers, street address information and more. | */ 'faker_locale' => 'en_US', /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is used by the Illuminate encrypter service and should be set | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | */ 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC', /* |-------------------------------------------------------------------------- | Autoloaded Service Providers |-------------------------------------------------------------------------- | | The service providers listed here will be automatically loaded on the | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | */ 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, /* * Package Service Providers... */ /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\HorizonServiceProvider::class, App\Providers\RouteServiceProvider::class, ], /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Arr' => Illuminate\Support\Arr::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'Date' => Illuminate\Support\Facades\Date::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Http' => Illuminate\Support\Facades\Http::class, 'Js' => Illuminate\Support\Js::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, // 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'Str' => Illuminate\Support\Str::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, ], ]; ================================================ FILE: config/auth.php ================================================ [ 'guard' => 'web', 'passwords' => 'users', ], /* |-------------------------------------------------------------------------- | Authentication Guards |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. | Of course, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | Supported: "session" | */ 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], ], /* |-------------------------------------------------------------------------- | User Providers |-------------------------------------------------------------------------- | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | If you have multiple user tables or models you may configure multiple | sources which represent each model / table. These sources may then | be assigned to any extra authentication guards you have defined. | | Supported: "database", "eloquent" | */ 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], // 'users' => [ // 'driver' => 'database', // 'table' => 'users', // ], ], /* |-------------------------------------------------------------------------- | Resetting Passwords |-------------------------------------------------------------------------- | | You may specify multiple password reset configurations if you have more | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. | | The expire time is the number of minutes that the reset token should be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | */ 'passwords' => [ 'users' => [ 'provider' => 'users', 'table' => 'password_resets', 'expire' => 60, 'throttle' => 60, ], ], /* |-------------------------------------------------------------------------- | Password Confirmation Timeout |-------------------------------------------------------------------------- | | Here you may define the amount of seconds before a password confirmation | times out and the user is prompted to re-enter their password via the | confirmation screen. By default, the timeout lasts for three hours. | */ 'password_timeout' => 10800, ]; ================================================ FILE: config/broadcasting.php ================================================ env('BROADCAST_DRIVER', 'null'), /* |-------------------------------------------------------------------------- | Broadcast Connections |-------------------------------------------------------------------------- | | Here you may define all of the broadcast connections that will be used | to broadcast events to other systems or over websockets. Samples of | each available type of connection are provided inside this array. | */ 'connections' => [ 'pusher' => [ 'driver' => 'pusher', 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), 'useTLS' => true, ], ], 'ably' => [ 'driver' => 'ably', 'key' => env('ABLY_KEY'), ], 'redis' => [ 'driver' => 'redis', 'connection' => 'default', ], 'log' => [ 'driver' => 'log', ], 'null' => [ 'driver' => 'null', ], ], ]; ================================================ FILE: config/cache.php ================================================ env('CACHE_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Cache Stores |-------------------------------------------------------------------------- | | Here you may define all of the cache "stores" for your application as | well as their drivers. You may even define multiple stores for the | same cache driver to group types of items stored in your caches. | | Supported drivers: "apc", "array", "database", "file", | "memcached", "redis", "dynamodb", "octane", "null" | */ 'stores' => [ 'apc' => [ 'driver' => 'apc', ], 'array' => [ 'driver' => 'array', 'serialize' => false, ], 'database' => [ 'driver' => 'database', 'table' => 'cache', 'connection' => null, 'lock_connection' => null, ], 'file' => [ 'driver' => 'file', 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], 'options' => [ // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ 'driver' => 'redis', 'connection' => 'cache', 'lock_connection' => 'default', ], 'dynamodb' => [ 'driver' => 'dynamodb', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 'endpoint' => env('DYNAMODB_ENDPOINT'), ], 'octane' => [ 'driver' => 'octane', ], ], /* |-------------------------------------------------------------------------- | Cache Key Prefix |-------------------------------------------------------------------------- | | When utilizing a RAM based store such as APC or Memcached, there might | be other applications utilizing the same cache. So, we'll specify a | value to get prefixed to all our keys so we can avoid collisions. | */ 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), ]; ================================================ FILE: config/cors.php ================================================ ['api/*', 'sanctum/csrf-cookie'], 'allowed_methods' => ['*'], 'allowed_origins' => ['*'], 'allowed_origins_patterns' => [], 'allowed_headers' => ['*'], 'exposed_headers' => [], 'max_age' => 0, 'supports_credentials' => false, ]; ================================================ FILE: config/database.php ================================================ env('DB_CONNECTION', 'mysql'), /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, 'schema' => 'public', 'sslmode' => 'prefer', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, ], ], /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk haven't actually been run in the database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer body of commands than a typical key-value system | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ 'client' => env('REDIS_CLIENT', 'phpredis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_DB', '0'), ], 'cache' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_CACHE_DB', '1'), ], ], ]; ================================================ FILE: config/filesystems.php ================================================ env('FILESYSTEM_DRIVER', 'local'), /* |-------------------------------------------------------------------------- | Filesystem Disks |-------------------------------------------------------------------------- | | Here you may configure as many filesystem "disks" as you wish, and you | may even configure multiple disks of the same driver. Defaults have | been setup for each driver as an example of the required options. | | Supported Drivers: "local", "ftp", "sftp", "s3" | */ 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), 'endpoint' => env('AWS_ENDPOINT'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), ], ], /* |-------------------------------------------------------------------------- | Symbolic Links |-------------------------------------------------------------------------- | | Here you may configure the symbolic links that will be created when the | `storage:link` Artisan command is executed. The array keys should be | the locations of the links and the values should be their targets. | */ 'links' => [ public_path('storage') => storage_path('app/public'), ], ]; ================================================ FILE: config/hashing.php ================================================ 'bcrypt', /* |-------------------------------------------------------------------------- | Bcrypt Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Bcrypt algorithm. This will allow you | to control the amount of time it takes to hash the given password. | */ 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], /* |-------------------------------------------------------------------------- | Argon Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Argon algorithm. These will allow you | to control the amount of time it takes to hash the given password. | */ 'argon' => [ 'memory' => 1024, 'threads' => 2, 'time' => 2, ], ]; ================================================ FILE: config/horizon.php ================================================ env('HORIZON_DOMAIN', null), /* |-------------------------------------------------------------------------- | Horizon Path |-------------------------------------------------------------------------- | | This is the URI path where Horizon will be accessible from. Feel free | to change this path to anything you like. Note that the URI will not | affect the paths of its internal API that aren't exposed to users. | */ 'path' => env('HORIZON_PATH', 'horizon'), /* |-------------------------------------------------------------------------- | Horizon Redis Connection |-------------------------------------------------------------------------- | | This is the name of the Redis connection where Horizon will store the | meta information required for it to function. It includes the list | of supervisors, failed jobs, job metrics, and other information. | */ 'use' => 'default', /* |-------------------------------------------------------------------------- | Horizon Redis Prefix |-------------------------------------------------------------------------- | | This prefix will be used when storing all Horizon data in Redis. You | may modify the prefix when you are running multiple installations | of Horizon on the same server so that they don't have problems. | */ 'prefix' => env( 'HORIZON_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_horizon:' ), /* |-------------------------------------------------------------------------- | Horizon Route Middleware |-------------------------------------------------------------------------- | | These middleware will get attached onto each Horizon route, giving you | the chance to add your own middleware to this list or change any of | the existing middleware. Or, you can simply stick with this list. | */ 'middleware' => ['web'], /* |-------------------------------------------------------------------------- | Queue Wait Time Thresholds |-------------------------------------------------------------------------- | | This option allows you to configure when the LongWaitDetected event | will be fired. Every connection / queue combination may have its | own, unique threshold (in seconds) before this event is fired. | */ 'waits' => [ 'redis:default' => 60, ], /* |-------------------------------------------------------------------------- | Job Trimming Times |-------------------------------------------------------------------------- | | Here you can configure for how long (in minutes) you desire Horizon to | persist the recent and failed jobs. Typically, recent jobs are kept | for one hour while all failed jobs are stored for an entire week. | */ 'trim' => [ 'recent' => 60, 'pending' => 60, 'completed' => 60, 'recent_failed' => 10080, 'failed' => 10080, 'monitored' => 10080, ], /* |-------------------------------------------------------------------------- | Metrics |-------------------------------------------------------------------------- | | Here you can configure how many snapshots should be kept to display in | the metrics graph. This will get used in combination with Horizon's | `horizon:snapshot` schedule to define how long to retain metrics. | */ 'metrics' => [ 'trim_snapshots' => [ 'job' => 24, 'queue' => 24, ], ], /* |-------------------------------------------------------------------------- | Fast Termination |-------------------------------------------------------------------------- | | When this option is enabled, Horizon's "terminate" command will not | wait on all of the workers to terminate unless the --wait option | is provided. Fast termination can shorten deployment delay by | allowing a new instance of Horizon to start while the last | instance will continue to terminate each of its workers. | */ 'fast_termination' => false, /* |-------------------------------------------------------------------------- | Memory Limit (MB) |-------------------------------------------------------------------------- | | This value describes the maximum amount of memory the Horizon master | supervisor may consume before it is terminated and restarted. For | configuring these limits on your workers, see the next section. | */ 'memory_limit' => 64, /* |-------------------------------------------------------------------------- | Queue Worker Configuration |-------------------------------------------------------------------------- | | Here you may define the queue worker settings used by your application | in all environments. These supervisors and settings handle all your | queued jobs and will be provisioned by Horizon during deployment. | */ 'defaults' => [ 'supervisor-1' => [ 'connection' => 'redis', 'queue' => ['default'], 'balance' => 'auto', 'maxProcesses' => 1, 'memory' => 128, 'tries' => 1, 'nice' => 0, ], ], 'environments' => [ 'production' => [ 'supervisor-1' => [ 'maxProcesses' => 10, 'balanceMaxShift' => 1, 'balanceCooldown' => 3, ], ], 'local' => [ 'supervisor-1' => [ 'maxProcesses' => 3, ], ], ], ]; ================================================ FILE: config/logging.php ================================================ env('LOG_CHANNEL', 'stack'), /* |-------------------------------------------------------------------------- | Deprecations Log Channel |-------------------------------------------------------------------------- | | This option controls the log channel that should be used to log warnings | regarding deprecated PHP and library features. This allows you to get | your application ready for upcoming major versions of dependencies. | */ 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), /* |-------------------------------------------------------------------------- | Log Channels |-------------------------------------------------------------------------- | | Here you may configure the log channels for your application. Out of | the box, Laravel uses the Monolog PHP logging library. This gives | you a variety of powerful log handlers / formatters to utilize. | | Available Drivers: "single", "daily", "slack", "syslog", | "errorlog", "monolog", | "custom", "stack" | */ 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], 'ignore_exceptions' => false, ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', 'emoji' => ':boom:', 'level' => env('LOG_LEVEL', 'critical'), ], 'papertrail' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => SyslogUdpHandler::class, 'handler_with' => [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), ], ], 'stderr' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => StreamHandler::class, 'formatter' => env('LOG_STDERR_FORMATTER'), 'with' => [ 'stream' => 'php://stderr', ], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), ], 'null' => [ 'driver' => 'monolog', 'handler' => NullHandler::class, ], 'emergency' => [ 'path' => storage_path('logs/laravel.log'), ], ], ]; ================================================ FILE: config/mail.php ================================================ env('MAIL_MAILER', 'smtp'), /* |-------------------------------------------------------------------------- | Mailer Configurations |-------------------------------------------------------------------------- | | Here you may configure all of the mailers used by your application plus | their respective settings. Several examples have been configured for | you and you are free to add your own as your application requires. | | Laravel supports a variety of mail "transport" drivers to be used while | sending an e-mail. You will specify which one you are using for your | mailers below. You are free to add additional mailers as required. | | Supported: "smtp", "sendmail", "mailgun", "ses", | "postmark", "log", "array", "failover" | */ 'mailers' => [ 'smtp' => [ 'transport' => 'smtp', 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'port' => env('MAIL_PORT', 587), 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'timeout' => null, 'auth_mode' => null, ], 'ses' => [ 'transport' => 'ses', ], 'mailgun' => [ 'transport' => 'mailgun', ], 'postmark' => [ 'transport' => 'postmark', ], 'sendmail' => [ 'transport' => 'sendmail', 'path' => '/usr/sbin/sendmail -bs', ], 'log' => [ 'transport' => 'log', 'channel' => env('MAIL_LOG_CHANNEL'), ], 'array' => [ 'transport' => 'array', ], 'failover' => [ 'transport' => 'failover', 'mailers' => [ 'smtp', 'log', ], ], ], /* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mails sent by your application to be sent from | the same address. Here, you may specify a name and address that is | used globally for all e-mails that are sent by your application. | */ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* |-------------------------------------------------------------------------- | Markdown Mail Settings |-------------------------------------------------------------------------- | | If you are using Markdown based email rendering, you may configure your | theme and component paths here, allowing you to customize the design | of the emails. Or, you may simply stick with the Laravel defaults! | */ 'markdown' => [ 'theme' => 'default', 'paths' => [ resource_path('views/vendor/mail'), ], ], ]; ================================================ FILE: config/queue.php ================================================ env('QUEUE_CONNECTION', 'sync'), /* |-------------------------------------------------------------------------- | Queue Connections |-------------------------------------------------------------------------- | | Here you may configure the connection information for each server that | is used by your application. A default configuration has been added | for each back-end shipped with Laravel. You are free to add more. | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ 'connections' => [ 'sync' => [ 'driver' => 'sync', ], 'database' => [ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', 'retry_after' => 90, 'after_commit' => false, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', 'retry_after' => 90, 'block_for' => 0, 'after_commit' => false, ], 'sqs' => [ 'driver' => 'sqs', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_QUEUE', 'default'), 'suffix' => env('SQS_SUFFIX'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'after_commit' => false, ], 'redis' => [ 'driver' => 'redis', 'connection' => 'default', 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90, 'block_for' => null, 'after_commit' => false, ], ], /* |-------------------------------------------------------------------------- | Failed Queue Jobs |-------------------------------------------------------------------------- | | These options configure the behavior of failed queue job logging so you | can control which database and table are used to store the jobs that | have failed. You may change them to any database / table you wish. | */ 'failed' => [ 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 'database' => env('DB_CONNECTION', 'mysql'), 'table' => 'failed_jobs', ], ]; ================================================ FILE: config/sanctum.php ================================================ explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( '%s%s', 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' ))), /* |-------------------------------------------------------------------------- | Sanctum Guards |-------------------------------------------------------------------------- | | This array contains the authentication guards that will be checked when | Sanctum is trying to authenticate a request. If none of these guards | are able to authenticate the request, Sanctum will use the bearer | token that's present on an incoming request for authentication. | */ 'guard' => ['web'], /* |-------------------------------------------------------------------------- | Expiration Minutes |-------------------------------------------------------------------------- | | This value controls the number of minutes until an issued token will be | considered expired. If this value is null, personal access tokens do | not expire. This won't tweak the lifetime of first-party sessions. | */ 'expiration' => null, /* |-------------------------------------------------------------------------- | Sanctum Middleware |-------------------------------------------------------------------------- | | When authenticating your first-party SPA with Sanctum you may need to | customize some of the middleware Sanctum uses while processing the | request. You may change the middleware listed below as required. | */ 'middleware' => [ 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, ], ]; ================================================ FILE: config/services.php ================================================ [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], 'ses' => [ 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], ]; ================================================ FILE: config/session.php ================================================ env('SESSION_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Session Lifetime |-------------------------------------------------------------------------- | | Here you may specify the number of minutes that you wish the session | to be allowed to remain idle before it expires. If you want them | to immediately expire on the browser closing, set that option. | */ 'lifetime' => env('SESSION_LIFETIME', 120), 'expire_on_close' => false, /* |-------------------------------------------------------------------------- | Session Encryption |-------------------------------------------------------------------------- | | This option allows you to easily specify that all of your session data | should be encrypted before it is stored. All encryption will be run | automatically by Laravel and you can use the Session like normal. | */ 'encrypt' => false, /* |-------------------------------------------------------------------------- | Session File Location |-------------------------------------------------------------------------- | | When using the native session driver, we need a location where session | files may be stored. A default has been set for you but a different | location may be specified. This is only needed for file sessions. | */ 'files' => storage_path('framework/sessions'), /* |-------------------------------------------------------------------------- | Session Database Connection |-------------------------------------------------------------------------- | | When using the "database" or "redis" session drivers, you may specify a | connection that should be used to manage these sessions. This should | correspond to a connection in your database configuration options. | */ 'connection' => env('SESSION_CONNECTION', null), /* |-------------------------------------------------------------------------- | Session Database Table |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we | should use to manage the sessions. Of course, a sensible default is | provided for you; however, you are free to change this as needed. | */ 'table' => 'sessions', /* |-------------------------------------------------------------------------- | Session Cache Store |-------------------------------------------------------------------------- | | While using one of the framework's cache driven session backends you may | list a cache store that should be used for these sessions. This value | must match with one of the application's configured cache "stores". | | Affects: "apc", "dynamodb", "memcached", "redis" | */ 'store' => env('SESSION_STORE', null), /* |-------------------------------------------------------------------------- | Session Sweeping Lottery |-------------------------------------------------------------------------- | | Some session drivers must manually sweep their storage location to get | rid of old sessions from storage. Here are the chances that it will | happen on a given request. By default, the odds are 2 out of 100. | */ 'lottery' => [2, 100], /* |-------------------------------------------------------------------------- | Session Cookie Name |-------------------------------------------------------------------------- | | Here you may change the name of the cookie used to identify a session | instance by ID. The name specified here will get used every time a | new session cookie is created by the framework for every driver. | */ 'cookie' => env( 'SESSION_COOKIE', Str::slug(env('APP_NAME', 'laravel'), '_').'_session' ), /* |-------------------------------------------------------------------------- | Session Cookie Path |-------------------------------------------------------------------------- | | The session cookie path determines the path for which the cookie will | be regarded as available. Typically, this will be the root path of | your application but you are free to change this when necessary. | */ 'path' => '/', /* |-------------------------------------------------------------------------- | Session Cookie Domain |-------------------------------------------------------------------------- | | Here you may change the domain of the cookie used to identify a session | in your application. This will determine which domains the cookie is | available to in your application. A sensible default has been set. | */ 'domain' => env('SESSION_DOMAIN', null), /* |-------------------------------------------------------------------------- | HTTPS Only Cookies |-------------------------------------------------------------------------- | | By setting this option to true, session cookies will only be sent back | to the server if the browser has a HTTPS connection. This will keep | the cookie from being sent to you when it can't be done securely. | */ 'secure' => env('SESSION_SECURE_COOKIE'), /* |-------------------------------------------------------------------------- | HTTP Access Only |-------------------------------------------------------------------------- | | Setting this value to true will prevent JavaScript from accessing the | value of the cookie and the cookie will only be accessible through | the HTTP protocol. You are free to modify this option if needed. | */ 'http_only' => true, /* |-------------------------------------------------------------------------- | Same-Site Cookies |-------------------------------------------------------------------------- | | This option determines how your cookies behave when cross-site requests | take place, and can be used to mitigate CSRF attacks. By default, we | will set this value to "lax" since this is a secure default value. | | Supported: "lax", "strict", "none", null | */ 'same_site' => 'lax', ]; ================================================ FILE: config/view.php ================================================ [ resource_path('views'), ], /* |-------------------------------------------------------------------------- | Compiled View Path |-------------------------------------------------------------------------- | | This option determines where all the compiled Blade templates will be | stored for your application. Typically, this is within the storage | directory. However, as usual, you are free to change this value. | */ 'compiled' => env( 'VIEW_COMPILED_PATH', realpath(storage_path('framework/views')) ), ]; ================================================ FILE: database/.gitignore ================================================ *.sqlite* ================================================ FILE: database/factories/CategoryFactory.php ================================================ $this->faker->words(2, true), ]; } } ================================================ FILE: database/factories/CommentFactory.php ================================================ User::factory(), 'idea_id' => Idea::factory(), 'status_id' => Status::factory(), 'body' => $this->faker->paragraph(5), ]; } public function existing() { return $this->state(function (array $attributes) { return [ 'user_id' => $this->faker->numberBetween(1, 20), 'status_id' => 1, ]; }); } } ================================================ FILE: database/factories/IdeaFactory.php ================================================ User::factory(), 'category_id' => Category::factory(), 'status_id' => Status::factory(), 'title' => ucwords($this->faker->words(4, true)), 'description' => $this->faker->paragraph(5), ]; } public function existing() { return $this->state(function(array $attributes) { return [ 'user_id' => $this->faker->numberBetween(1, 20), 'category_id' => $this->faker->numberBetween(1, 4), 'status_id' => $this->faker->numberBetween(1, 5), ]; }); } } ================================================ FILE: database/factories/StatusFactory.php ================================================ $this->faker->words(2, true), ]; } } ================================================ FILE: database/factories/UserFactory.php ================================================ $this->faker->firstName, 'email' => $this->faker->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'remember_token' => Str::random(10), ]; } /** * Indicate that the model's email address should be unverified. * * @return \Illuminate\Database\Eloquent\Factories\Factory */ public function unverified() { return $this->state(function (array $attributes) { return [ 'email_verified_at' => null, ]; }); } } ================================================ FILE: database/factories/VoteFactory.php ================================================ $this->faker->numberBetween(1, 100), 'user_id' => $this->faker->numberBetween(1, 20), ]; } } ================================================ FILE: database/migrations/2014_10_12_000000_create_users_table.php ================================================ id(); $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } ================================================ FILE: database/migrations/2014_10_12_100000_create_password_resets_table.php ================================================ string('email')->index(); $table->string('token'); $table->timestamp('created_at')->nullable(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('password_resets'); } } ================================================ FILE: database/migrations/2019_08_19_000000_create_failed_jobs_table.php ================================================ id(); $table->string('uuid')->unique(); $table->text('connection'); $table->text('queue'); $table->longText('payload'); $table->longText('exception'); $table->timestamp('failed_at')->useCurrent(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('failed_jobs'); } } ================================================ FILE: database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php ================================================ id(); $table->morphs('tokenable'); $table->string('name'); $table->string('token', 64)->unique(); $table->text('abilities')->nullable(); $table->timestamp('last_used_at')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('personal_access_tokens'); } } ================================================ FILE: database/migrations/2021_11_19_154310_create_statuses_table.php ================================================ id(); $table->string('name'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('statuses'); } } ================================================ FILE: database/migrations/2021_11_20_154310_create_categories_table.php ================================================ id(); $table->string('name'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('categories'); } } ================================================ FILE: database/migrations/2021_11_21_154310_create_ideas_table.php ================================================ id(); $table->foreignId('user_id')->constrained(); $table->foreignId('category_id')->constrained(); $table->foreignId('status_id')->constrained(); $table->string('title'); $table->string('slug')->nullable(); $table->text('description'); $table->integer('spam_reports')->default(0); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('ideas'); } } ================================================ FILE: database/migrations/2021_11_24_195521_create_votes_table.php ================================================ id(); $table->unique(['idea_id', 'user_id']); $table->foreignId('idea_id')->constrained(); $table->foreignId('user_id')->constrained(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('votes'); } } ================================================ FILE: database/migrations/2021_12_19_130759_create_comments_table.php ================================================ id(); $table->foreignId('user_id')->constrained(); $table->foreignId('idea_id')->constrained(); $table->foreignId('status_id')->constrained(); $table->text('body'); $table->integer('spam_reports')->default(0); $table->boolean('is_status_update')->default(false); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('comments'); } } ================================================ FILE: database/migrations/2021_12_28_133951_create_notifications_table.php ================================================ uuid('id')->primary(); $table->string('type'); $table->morphs('notifiable'); $table->text('data'); $table->timestamp('read_at')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('notifications'); } } ================================================ FILE: database/seeders/CategorySeeder.php ================================================ create([ 'name' => 'luka', 'email' => 'lukabrazi@redberry.ge', 'password' => Hash::make('lukakiller123'), ]); User::factory(19)->create(); Category::factory()->create(['name' => 'Category 1']); Category::factory()->create(['name' => 'Category 2']); Category::factory()->create(['name' => 'Category 3']); Category::factory()->create(['name' => 'Category 4']); Status::factory()->create(['name' => 'Open']); Status::factory()->create(['name' => 'Considering']); Status::factory()->create(['name' => 'In Progress']); Status::factory()->create(['name' => 'Implemented']); Status::factory()->create(['name' => 'Closed']); Idea::factory(100)->existing()->create(); // Generate unique votes. Ensure idea_id and user_id are unique for each row foreach (range(1, 20) as $user_id) { foreach (range(1, 100) as $idea_id) { if ($idea_id % 2 === 0) { Vote::factory()->create([ 'user_id' => $user_id, 'idea_id' => $idea_id, ]); } } } // Generate comments for ideas foreach (Idea::all() as $idea) { Comment::factory(5)->existing()->create(['idea_id' => $idea->id]); } } } ================================================ FILE: database/seeders/IdeaSeeder.php ================================================