├── public ├── favicon.ico ├── robots.txt ├── index.php └── .htaccess ├── database ├── .gitignore ├── factories │ ├── ArticleFactory.php │ └── UserFactory.php ├── migrations │ ├── 2024_05_23_025258_create_articles_table.php │ ├── 0001_01_01_000001_create_cache_table.php │ ├── 0001_01_01_000000_create_users_table.php │ └── 0001_01_01_000002_create_jobs_table.php └── seeders │ ├── ArticleSeeder.php │ └── DatabaseSeeder.php ├── bootstrap ├── cache │ └── .gitignore ├── providers.php └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── resources ├── css │ └── app.css ├── js │ ├── Components │ │ ├── InputError.jsx │ │ ├── InputLabel.jsx │ │ ├── Checkbox.jsx │ │ ├── DangerButton.jsx │ │ ├── TextInput.jsx │ │ ├── PrimaryButton.jsx │ │ ├── NavLink.jsx │ │ ├── SecondaryButton.jsx │ │ ├── ResponsiveNavLink.jsx │ │ ├── DeleteIcon.jsx │ │ ├── ThumbsUp.jsx │ │ ├── Modal.jsx │ │ ├── ApplicationLogo.jsx │ │ ├── Dropdown.jsx │ │ ├── Notification.jsx │ │ └── DeleteNotification.jsx │ ├── bootstrap.js │ ├── echo.js │ ├── Layouts │ │ ├── GuestLayout.jsx │ │ └── AuthenticatedLayout.jsx │ ├── app.jsx │ └── Pages │ │ ├── Profile │ │ ├── Edit.jsx │ │ └── Partials │ │ │ ├── DeleteUserForm.jsx │ │ │ ├── UpdateProfileInformationForm.jsx │ │ │ └── UpdatePasswordForm.jsx │ │ ├── Auth │ │ ├── VerifyEmail.jsx │ │ ├── ForgotPassword.jsx │ │ ├── ConfirmPassword.jsx │ │ ├── ResetPassword.jsx │ │ ├── Login.jsx │ │ └── Register.jsx │ │ └── Dashboard.jsx └── views │ └── app.blade.php ├── tests ├── Unit │ └── ExampleTest.php ├── Feature │ ├── ExampleTest.php │ ├── Auth │ │ ├── RegistrationTest.php │ │ ├── PasswordConfirmationTest.php │ │ ├── AuthenticationTest.php │ │ ├── PasswordUpdateTest.php │ │ ├── EmailVerificationTest.php │ │ └── PasswordResetTest.php │ └── ProfileTest.php ├── TestCase.php └── Pest.php ├── postcss.config.js ├── app ├── Http │ ├── Controllers │ │ ├── Controller.php │ │ ├── ArticleController.php │ │ ├── Auth │ │ │ ├── EmailVerificationPromptController.php │ │ │ ├── EmailVerificationNotificationController.php │ │ │ ├── PasswordController.php │ │ │ ├── VerifyEmailController.php │ │ │ ├── ConfirmablePasswordController.php │ │ │ ├── AuthenticatedSessionController.php │ │ │ ├── RegisteredUserController.php │ │ │ ├── PasswordResetLinkController.php │ │ │ └── NewPasswordController.php │ │ ├── DeleteArticleRequestController.php │ │ └── ProfileController.php │ ├── Requests │ │ ├── ProfileUpdateRequest.php │ │ └── Auth │ │ │ └── LoginRequest.php │ └── Middleware │ │ └── HandleInertiaRequests.php ├── Providers │ └── AppServiceProvider.php ├── Models │ ├── Scopes │ │ └── UserArticleScope.php │ ├── Article.php │ └── User.php └── Events │ ├── ArticleDeleted.php │ └── DeleteArticleRequestReceived.php ├── .prettierrc ├── .gitattributes ├── routes ├── channels.php ├── console.php ├── web.php └── auth.php ├── jsconfig.json ├── .editorconfig ├── .gitignore ├── vite.config.js ├── artisan ├── tailwind.config.js ├── package.json ├── config ├── services.php ├── filesystems.php ├── broadcasting.php ├── reverb.php ├── cache.php ├── mail.php ├── queue.php ├── auth.php ├── app.php ├── logging.php ├── database.php └── session.php ├── phpunit.xml ├── .env.example ├── composer.json └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | get('/'); 5 | 6 | $response->assertStatus(200); 7 | }); 8 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 8 | }); 9 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote')->hourly(); 9 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/*": ["resources/js/*"], 6 | "ziggy-js": ["./vendor/tightenco/ziggy"] 7 | } 8 | }, 9 | "exclude": ["node_modules", "public"] 10 | } 11 | -------------------------------------------------------------------------------- /resources/js/Components/InputError.jsx: -------------------------------------------------------------------------------- 1 | export default function InputError({ message, className = '', ...props }) { 2 | return message ? ( 3 |

4 | {message} 5 |

6 | ) : null; 7 | } 8 | -------------------------------------------------------------------------------- /resources/js/Components/InputLabel.jsx: -------------------------------------------------------------------------------- 1 | export default function InputLabel({ value, className = '', children, ...props }) { 2 | return ( 3 | 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /node_modules 3 | /public/build 4 | /public/hot 5 | /public/storage 6 | /storage/*.key 7 | /vendor 8 | .env 9 | .env.backup 10 | .env.production 11 | .phpactor.json 12 | .phpunit.result.cache 13 | Homestead.json 14 | Homestead.yaml 15 | auth.json 16 | npm-debug.log 17 | yarn-error.log 18 | /.fleet 19 | /.idea 20 | /.vscode 21 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import react from '@vitejs/plugin-react'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: 'resources/js/app.jsx', 9 | refresh: true, 10 | }), 11 | react(), 12 | ], 13 | }); 14 | -------------------------------------------------------------------------------- /resources/js/Components/Checkbox.jsx: -------------------------------------------------------------------------------- 1 | export default function Checkbox({ className = '', ...props }) { 2 | return ( 3 | 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | handleCommand(new ArgvInput); 14 | 15 | exit($status); 16 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | window.axios = axios; 3 | 4 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 5 | 6 | /** 7 | * Echo exposes an expressive API for subscribing to channels and listening 8 | * for events that are broadcast by Laravel. Echo and event broadcasting 9 | * allow your team to quickly build robust real-time web applications. 10 | */ 11 | 12 | import './echo'; 13 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 18 | -------------------------------------------------------------------------------- /app/Http/Controllers/ArticleController.php: -------------------------------------------------------------------------------- 1 | id); 14 | $article_data = $article->toArray(); 15 | $article_user = $article->user; 16 | 17 | $article->delete(); 18 | 19 | broadcast(new ArticleDeleted($article_data, $article_user)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | get('/register'); 5 | 6 | $response->assertStatus(200); 7 | }); 8 | 9 | test('new users can register', function () { 10 | $response = $this->post('/register', [ 11 | 'name' => 'Test User', 12 | 'email' => 'test@example.com', 13 | 'password' => 'password', 14 | 'password_confirmation' => 'password', 15 | ]); 16 | 17 | $this->assertAuthenticated(); 18 | $response->assertRedirect(route('dashboard', absolute: false)); 19 | }); 20 | -------------------------------------------------------------------------------- /app/Models/Scopes/UserArticleScope.php: -------------------------------------------------------------------------------- 1 | role === 'editor') { 18 | $builder->where('user_id', Auth::id()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /resources/js/Layouts/GuestLayout.jsx: -------------------------------------------------------------------------------- 1 | import ApplicationLogo from '@/Components/ApplicationLogo'; 2 | import { Link } from '@inertiajs/react'; 3 | 4 | export default function Guest({ children }) { 5 | return ( 6 |
7 |
8 | 9 | 10 | 11 |
12 | 13 |
14 | {children} 15 |
16 |
17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /resources/js/Components/DangerButton.jsx: -------------------------------------------------------------------------------- 1 | export default function DangerButton({ className = '', disabled, children, ...props }) { 2 | return ( 3 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /app/Http/Requests/ProfileUpdateRequest.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function rules(): array 17 | { 18 | return [ 19 | 'name' => ['required', 'string', 'max:255'], 20 | 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)], 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/js/Components/TextInput.jsx: -------------------------------------------------------------------------------- 1 | import { forwardRef, useEffect, useRef } from 'react' 2 | 3 | export default forwardRef(function TextInput( 4 | { type = 'text', className = '', isFocused = false, ...props }, 5 | ref 6 | ) { 7 | const input = ref ? ref : useRef() 8 | 9 | useEffect(() => { 10 | if (isFocused) { 11 | input.current.focus() 12 | } 13 | }, []) 14 | 15 | return ( 16 | 25 | ) 26 | }) 27 | -------------------------------------------------------------------------------- /resources/js/Components/PrimaryButton.jsx: -------------------------------------------------------------------------------- 1 | export default function PrimaryButton({ className = '', disabled, children, ...props }) { 2 | return ( 3 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationPromptController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail() 19 | ? redirect()->intended(route('dashboard', absolute: false)) 20 | : Inertia::render('Auth/VerifyEmail', ['status' => session('status')]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Controllers/DeleteArticleRequestController.php: -------------------------------------------------------------------------------- 1 | id); 18 | 19 | $chief = User::where('role', 'chief-editor')->first(); 20 | $editor = User::find($request->user_id); 21 | 22 | // Broadcast the event for the chief editor 23 | broadcast(new DeleteArticleRequestReceived($article, $chief, $editor)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | import defaultTheme from 'tailwindcss/defaultTheme' 2 | const { nextui } = require('@nextui-org/react') 3 | 4 | /** @type {import('tailwindcss').Config} */ 5 | export default { 6 | content: [ 7 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', 8 | './storage/framework/views/*.php', 9 | './resources/views/**/*.blade.php', 10 | './resources/js/**/*.jsx', 11 | './node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}' 12 | ], 13 | 14 | theme: { 15 | extend: { 16 | fontFamily: { 17 | sans: ['Inter Tight', ...defaultTheme.fontFamily.sans] 18 | } 19 | } 20 | }, 21 | darkMode: 'class', 22 | plugins: [nextui()] 23 | } 24 | -------------------------------------------------------------------------------- /database/factories/ArticleFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class ArticleFactory extends Factory 13 | { 14 | /** 15 | * Define the model's default state. 16 | * 17 | * @return array 18 | */ 19 | public function definition(): array 20 | { 21 | return [ 22 | 'user_id' => User::factory(), 23 | 'title' => Str::ucfirst(fake()->words(7, true)), 24 | 'body' => fake()->paragraphs(10, true), 25 | 'is_active' => true, 26 | ]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationNotificationController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 17 | return redirect()->intended(route('dashboard', absolute: false)); 18 | } 19 | 20 | $request->user()->sendEmailVerificationNotification(); 21 | 22 | return back()->with('status', 'verification-link-sent'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/js/Components/NavLink.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from '@inertiajs/react'; 2 | 3 | export default function NavLink({ active = false, className = '', children, ...props }) { 4 | return ( 5 | 15 | {children} 16 | 17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /resources/js/Components/SecondaryButton.jsx: -------------------------------------------------------------------------------- 1 | export default function SecondaryButton({ type = 'button', className = '', disabled, children, ...props }) { 2 | return ( 3 | 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 9 | web: __DIR__.'/../routes/web.php', 10 | commands: __DIR__.'/../routes/console.php', 11 | channels: __DIR__.'/../routes/channels.php', 12 | health: '/up', 13 | ) 14 | ->withMiddleware(function (Middleware $middleware) { 15 | $middleware->web(append: [ 16 | \App\Http\Middleware\HandleInertiaRequests::class, 17 | \Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class, 18 | ]); 19 | 20 | // 21 | }) 22 | ->withExceptions(function (Exceptions $exceptions) { 23 | // 24 | })->create(); 25 | -------------------------------------------------------------------------------- /resources/js/Components/ResponsiveNavLink.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from '@inertiajs/react'; 2 | 3 | export default function ResponsiveNavLink({ active = false, className = '', children, ...props }) { 4 | return ( 5 | 13 | {children} 14 | 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 19 | 'current_password' => ['required', 'current_password'], 20 | 'password' => ['required', Password::defaults(), 'confirmed'], 21 | ]); 22 | 23 | $request->user()->update([ 24 | 'password' => Hash::make($validated['password']), 25 | ]); 26 | 27 | return back(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /resources/js/app.jsx: -------------------------------------------------------------------------------- 1 | import './bootstrap' 2 | import '../css/app.css' 3 | 4 | import { createRoot } from 'react-dom/client' 5 | import { createInertiaApp } from '@inertiajs/react' 6 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers' 7 | import { NextUIProvider } from '@nextui-org/react' 8 | 9 | const appName = import.meta.env.VITE_APP_NAME || 'Laravel' 10 | 11 | createInertiaApp({ 12 | title: title => `${title} - ${appName}`, 13 | resolve: name => 14 | resolvePageComponent( 15 | `./Pages/${name}.jsx`, 16 | import.meta.glob('./Pages/**/*.jsx') 17 | ), 18 | setup({ el, App, props }) { 19 | const root = createRoot(el) 20 | 21 | root.render( 22 | 23 | 24 | 25 | ) 26 | }, 27 | progress: { 28 | color: '#4B5563' 29 | } 30 | }) 31 | -------------------------------------------------------------------------------- /database/migrations/2024_05_23_025258_create_articles_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('user_id')->constrained(); 17 | $table->string('title'); 18 | $table->text('body'); 19 | $table->string('article_image', 1000); 20 | $table->boolean('is_active'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('articles'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build" 7 | }, 8 | "devDependencies": { 9 | "@headlessui/react": "^1.4.2", 10 | "@inertiajs/react": "^1.0.0", 11 | "@tailwindcss/forms": "^0.5.3", 12 | "@vitejs/plugin-react": "^4.2.0", 13 | "autoprefixer": "^10.4.12", 14 | "axios": "^1.6.4", 15 | "laravel-echo": "^1.16.1", 16 | "laravel-vite-plugin": "^1.0", 17 | "postcss": "^8.4.31", 18 | "prettier": "^3.2.5", 19 | "prettier-plugin-tailwindcss": "^0.5.14", 20 | "pusher-js": "^8.4.0-rc2", 21 | "react": "^18.2.0", 22 | "react-dom": "^18.2.0", 23 | "tailwindcss": "^3.2.1", 24 | "vite": "^5.0" 25 | }, 26 | "dependencies": { 27 | "@nextui-org/react": "^2.3.6", 28 | "framer-motion": "^11.2.6" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ config('app.name', 'Laravel') }} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | @routes 16 | @viteReactRefresh 17 | @vite(['resources/js/app.jsx', "resources/js/Pages/{$page['component']}.jsx"]) 18 | @inertiaHead 19 | 20 | 21 | @inertia 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerifyEmailController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 18 | return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); 19 | } 20 | 21 | if ($request->user()->markEmailAsVerified()) { 22 | event(new Verified($request->user())); 23 | } 24 | 25 | return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordConfirmationTest.php: -------------------------------------------------------------------------------- 1 | create(); 7 | 8 | $response = $this->actingAs($user)->get('/confirm-password'); 9 | 10 | $response->assertStatus(200); 11 | }); 12 | 13 | test('password can be confirmed', function () { 14 | $user = User::factory()->create(); 15 | 16 | $response = $this->actingAs($user)->post('/confirm-password', [ 17 | 'password' => 'password', 18 | ]); 19 | 20 | $response->assertRedirect(); 21 | $response->assertSessionHasNoErrors(); 22 | }); 23 | 24 | test('password is not confirmed with invalid password', function () { 25 | $user = User::factory()->create(); 26 | 27 | $response = $this->actingAs($user)->post('/confirm-password', [ 28 | 'password' => 'wrong-password', 29 | ]); 30 | 31 | $response->assertSessionHasErrors(); 32 | }); 33 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | public function share(Request $request): array 31 | { 32 | return [ 33 | ...parent::share($request), 34 | 'auth' => [ 35 | 'user' => $request->user(), 36 | ], 37 | ]; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/migrations/0001_01_01_000001_create_cache_table.php: -------------------------------------------------------------------------------- 1 | string('key')->primary(); 16 | $table->mediumText('value'); 17 | $table->integer('expiration'); 18 | }); 19 | 20 | Schema::create('cache_locks', function (Blueprint $table) { 21 | $table->string('key')->primary(); 22 | $table->string('owner'); 23 | $table->integer('expiration'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('cache'); 33 | Schema::dropIfExists('cache_locks'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /app/Events/ArticleDeleted.php: -------------------------------------------------------------------------------- 1 | 30 | */ 31 | public function broadcastOn(): array 32 | { 33 | return [ 34 | new PrivateChannel("management.{$this->editor->id}"), 35 | ]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/Feature/Auth/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get('/login'); 7 | 8 | $response->assertStatus(200); 9 | }); 10 | 11 | test('users can authenticate using the login screen', function () { 12 | $user = User::factory()->create(); 13 | 14 | $response = $this->post('/login', [ 15 | 'email' => $user->email, 16 | 'password' => 'password', 17 | ]); 18 | 19 | $this->assertAuthenticated(); 20 | $response->assertRedirect(route('dashboard', absolute: false)); 21 | }); 22 | 23 | test('users can not authenticate with invalid password', function () { 24 | $user = User::factory()->create(); 25 | 26 | $this->post('/login', [ 27 | 'email' => $user->email, 28 | 'password' => 'wrong-password', 29 | ]); 30 | 31 | $this->assertGuest(); 32 | }); 33 | 34 | test('users can logout', function () { 35 | $user = User::factory()->create(); 36 | 37 | $response = $this->actingAs($user)->post('/logout'); 38 | 39 | $this->assertGuest(); 40 | $response->assertRedirect('/'); 41 | }); 42 | -------------------------------------------------------------------------------- /app/Events/DeleteArticleRequestReceived.php: -------------------------------------------------------------------------------- 1 | 31 | */ 32 | public function broadcastOn(): array 33 | { 34 | return [ 35 | new PrivateChannel("management.{$this->chief->id}"), 36 | ]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Models/Article.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | protected $fillable = [ 22 | 'user_id', 23 | 'title', 24 | 'body', 25 | 'article_image', 26 | 'is_active', 27 | ]; 28 | 29 | /** 30 | * Cast the dates to human readable format. 31 | * 32 | * @var array 33 | */ 34 | protected $casts = [ 35 | 'created_at' => 'datetime:D, m/d/o', 36 | 'updated_at' => 'datetime:D, m/d/o', 37 | ]; 38 | 39 | /** 40 | * Get the user who owns the article. 41 | */ 42 | public function user(): BelongsTo 43 | { 44 | return $this->belongsTo(User::class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /resources/js/Components/DeleteIcon.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const DeleteIcon = () => { 4 | return ( 5 |
6 | 12 | 17 | 18 |
19 | ) 20 | } 21 | 22 | export default DeleteIcon 23 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'resend' => [ 28 | 'key' => env('RESEND_KEY'), 29 | ], 30 | 31 | 'slack' => [ 32 | 'notifications' => [ 33 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 34 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 35 | ], 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /resources/js/Components/ThumbsUp.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const ThumbsUp = () => { 4 | return ( 5 |
6 | 12 | 13 | 14 |
15 | ) 16 | } 17 | 18 | export default ThumbsUp 19 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ConfirmablePasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 29 | 'email' => $request->user()->email, 30 | 'password' => $request->password, 31 | ])) { 32 | throw ValidationException::withMessages([ 33 | 'password' => __('auth.password'), 34 | ]); 35 | } 36 | 37 | $request->session()->put('auth.password_confirmed_at', time()); 38 | 39 | return redirect()->intended(route('dashboard', absolute: false)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordUpdateTest.php: -------------------------------------------------------------------------------- 1 | create(); 8 | 9 | $response = $this 10 | ->actingAs($user) 11 | ->from('/profile') 12 | ->put('/password', [ 13 | 'current_password' => 'password', 14 | 'password' => 'new-password', 15 | 'password_confirmation' => 'new-password', 16 | ]); 17 | 18 | $response 19 | ->assertSessionHasNoErrors() 20 | ->assertRedirect('/profile'); 21 | 22 | $this->assertTrue(Hash::check('new-password', $user->refresh()->password)); 23 | }); 24 | 25 | test('correct password must be provided to update password', function () { 26 | $user = User::factory()->create(); 27 | 28 | $response = $this 29 | ->actingAs($user) 30 | ->from('/profile') 31 | ->put('/password', [ 32 | 'current_password' => 'wrong-password', 33 | 'password' => 'new-password', 34 | 'password_confirmation' => 'new-password', 35 | ]); 36 | 37 | $response 38 | ->assertSessionHasErrors('current_password') 39 | ->assertRedirect('/profile'); 40 | }); 41 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class UserFactory extends Factory 13 | { 14 | /** 15 | * The current password being used by the factory. 16 | */ 17 | protected static ?string $password; 18 | 19 | /** 20 | * Define the model's default state. 21 | * 22 | * @return array 23 | */ 24 | public function definition(): array 25 | { 26 | return [ 27 | 'role' => '', 28 | 'name' => fake()->name(), 29 | 'email' => fake()->unique()->safeEmail(), 30 | 'email_verified_at' => now(), 31 | 'password' => static::$password ??= Hash::make('password'), 32 | 'remember_token' => Str::random(10), 33 | ]; 34 | } 35 | 36 | /** 37 | * Indicate that the model's email address should be unverified. 38 | */ 39 | public function unverified(): static 40 | { 41 | return $this->state(fn (array $attributes) => [ 42 | 'email_verified_at' => null, 43 | ]); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests/Unit 10 | 11 | 12 | tests/Feature 13 | 14 | 15 | 16 | 17 | app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_TIMEZONE=UTC 6 | APP_URL=http://localhost 7 | 8 | APP_LOCALE=en 9 | APP_FALLBACK_LOCALE=en 10 | APP_FAKER_LOCALE=en_US 11 | 12 | APP_MAINTENANCE_DRIVER=file 13 | APP_MAINTENANCE_STORE=database 14 | 15 | BCRYPT_ROUNDS=12 16 | 17 | LOG_CHANNEL=stack 18 | LOG_STACK=single 19 | LOG_DEPRECATIONS_CHANNEL=null 20 | LOG_LEVEL=debug 21 | 22 | DB_CONNECTION=mysql 23 | DB_HOST=127.0.0.1 24 | DB_PORT=3306 25 | DB_DATABASE=funwithreverb 26 | DB_USERNAME=root 27 | DB_PASSWORD= 28 | 29 | SESSION_DRIVER=database 30 | SESSION_LIFETIME=120 31 | SESSION_ENCRYPT=false 32 | SESSION_PATH=/ 33 | SESSION_DOMAIN=null 34 | 35 | BROADCAST_CONNECTION=log 36 | FILESYSTEM_DISK=local 37 | QUEUE_CONNECTION=database 38 | 39 | CACHE_STORE=database 40 | CACHE_PREFIX= 41 | 42 | MEMCACHED_HOST=127.0.0.1 43 | 44 | REDIS_CLIENT=phpredis 45 | REDIS_HOST=127.0.0.1 46 | REDIS_PASSWORD=null 47 | REDIS_PORT=6379 48 | 49 | MAIL_MAILER=log 50 | MAIL_HOST=127.0.0.1 51 | MAIL_PORT=2525 52 | MAIL_USERNAME=null 53 | MAIL_PASSWORD=null 54 | MAIL_ENCRYPTION=null 55 | MAIL_FROM_ADDRESS="hello@example.com" 56 | MAIL_FROM_NAME="${APP_NAME}" 57 | 58 | AWS_ACCESS_KEY_ID= 59 | AWS_SECRET_ACCESS_KEY= 60 | AWS_DEFAULT_REGION=us-east-1 61 | AWS_BUCKET= 62 | AWS_USE_PATH_STYLE_ENDPOINT=false 63 | 64 | VITE_APP_NAME="${APP_NAME}" 65 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | Route::has('login'), 14 | 'canRegister' => Route::has('register'), 15 | 'laravelVersion' => Application::VERSION, 16 | 'phpVersion' => PHP_VERSION, 17 | ]); 18 | }); 19 | 20 | Route::get('/dashboard', function () { 21 | 22 | $articles = Article::simplePaginate(10); 23 | 24 | return Inertia::render('Dashboard', ['articles' => $articles]); 25 | 26 | })->middleware(['auth', 'verified'])->name('dashboard'); 27 | 28 | Route::middleware('auth')->group(function () { 29 | Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); 30 | Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update'); 31 | Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); 32 | 33 | Route::post('delete-article-request', DeleteArticleRequestController::class); 34 | Route::delete('/article', [ArticleController::class, 'destroy'])->name('article.destroy'); 35 | }); 36 | 37 | require __DIR__.'/auth.php'; 38 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | protected $fillable = [ 21 | 'role', 22 | 'name', 23 | 'email', 24 | 'password', 25 | ]; 26 | 27 | /** 28 | * The attributes that should be hidden for serialization. 29 | * 30 | * @var array 31 | */ 32 | protected $hidden = [ 33 | 'password', 34 | 'remember_token', 35 | ]; 36 | 37 | /** 38 | * Get the attributes that should be cast. 39 | * 40 | * @return array 41 | */ 42 | protected function casts(): array 43 | { 44 | return [ 45 | 'email_verified_at' => 'datetime', 46 | 'password' => 'hashed', 47 | ]; 48 | } 49 | 50 | /** 51 | * Get the articles associated with a user. 52 | */ 53 | public function articles(): HasMany 54 | { 55 | return $this->hasMany(Article::class); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | Route::has('password.request'), 23 | 'status' => session('status'), 24 | ]); 25 | } 26 | 27 | /** 28 | * Handle an incoming authentication request. 29 | */ 30 | public function store(LoginRequest $request): RedirectResponse 31 | { 32 | $request->authenticate(); 33 | 34 | $request->session()->regenerate(); 35 | 36 | return redirect()->intended(route('dashboard', absolute: false)); 37 | } 38 | 39 | /** 40 | * Destroy an authenticated session. 41 | */ 42 | public function destroy(Request $request): RedirectResponse 43 | { 44 | Auth::guard('web')->logout(); 45 | 46 | $request->session()->invalidate(); 47 | 48 | $request->session()->regenerateToken(); 49 | 50 | return redirect('/'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/Feature/Auth/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | unverified()->create(); 10 | 11 | $response = $this->actingAs($user)->get('/verify-email'); 12 | 13 | $response->assertStatus(200); 14 | }); 15 | 16 | test('email can be verified', function () { 17 | $user = User::factory()->unverified()->create(); 18 | 19 | Event::fake(); 20 | 21 | $verificationUrl = URL::temporarySignedRoute( 22 | 'verification.verify', 23 | now()->addMinutes(60), 24 | ['id' => $user->id, 'hash' => sha1($user->email)] 25 | ); 26 | 27 | $response = $this->actingAs($user)->get($verificationUrl); 28 | 29 | Event::assertDispatched(Verified::class); 30 | expect($user->fresh()->hasVerifiedEmail())->toBeTrue(); 31 | $response->assertRedirect(route('dashboard', absolute: false).'?verified=1'); 32 | }); 33 | 34 | test('email is not verified with invalid hash', function () { 35 | $user = User::factory()->unverified()->create(); 36 | 37 | $verificationUrl = URL::temporarySignedRoute( 38 | 'verification.verify', 39 | now()->addMinutes(60), 40 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 41 | ); 42 | 43 | $this->actingAs($user)->get($verificationUrl); 44 | 45 | expect($user->fresh()->hasVerifiedEmail())->toBeFalse(); 46 | }); 47 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisteredUserController.php: -------------------------------------------------------------------------------- 1 | validate([ 34 | 'name' => 'required|string|max:255', 35 | 'email' => 'required|string|lowercase|email|max:255|unique:'.User::class, 36 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 37 | ]); 38 | 39 | $user = User::create([ 40 | 'name' => $request->name, 41 | 'email' => $request->email, 42 | 'password' => Hash::make($request->password), 43 | ]); 44 | 45 | event(new Registered($user)); 46 | 47 | Auth::login($user); 48 | 49 | return redirect(route('dashboard', absolute: false)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Edit.jsx: -------------------------------------------------------------------------------- 1 | import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; 2 | import DeleteUserForm from './Partials/DeleteUserForm'; 3 | import UpdatePasswordForm from './Partials/UpdatePasswordForm'; 4 | import UpdateProfileInformationForm from './Partials/UpdateProfileInformationForm'; 5 | import { Head } from '@inertiajs/react'; 6 | 7 | export default function Edit({ auth, mustVerifyEmail, status }) { 8 | return ( 9 | Profile} 12 | > 13 | 14 | 15 |
16 |
17 |
18 | 23 |
24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 |
32 |
33 |
34 |
35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordResetLinkController.php: -------------------------------------------------------------------------------- 1 | session('status'), 22 | ]); 23 | } 24 | 25 | /** 26 | * Handle an incoming password reset link request. 27 | * 28 | * @throws \Illuminate\Validation\ValidationException 29 | */ 30 | public function store(Request $request): RedirectResponse 31 | { 32 | $request->validate([ 33 | 'email' => 'required|email', 34 | ]); 35 | 36 | // We will send the password reset link to this user. Once we have attempted 37 | // to send the link, we will examine the response then see the message we 38 | // need to show to the user. Finally, we'll send out a proper response. 39 | $status = Password::sendResetLink( 40 | $request->only('email') 41 | ); 42 | 43 | if ($status == Password::RESET_LINK_SENT) { 44 | return back()->with('status', __($status)); 45 | } 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => [trans($status)], 49 | ]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /database/migrations/0001_01_01_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('role'); 17 | $table->string('name'); 18 | $table->string('email')->unique(); 19 | $table->timestamp('email_verified_at')->nullable(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->timestamps(); 23 | }); 24 | 25 | Schema::create('password_reset_tokens', function (Blueprint $table) { 26 | $table->string('email')->primary(); 27 | $table->string('token'); 28 | $table->timestamp('created_at')->nullable(); 29 | }); 30 | 31 | Schema::create('sessions', function (Blueprint $table) { 32 | $table->string('id')->primary(); 33 | $table->foreignId('user_id')->nullable()->index(); 34 | $table->string('ip_address', 45)->nullable(); 35 | $table->text('user_agent')->nullable(); 36 | $table->longText('payload'); 37 | $table->integer('last_activity')->index(); 38 | }); 39 | } 40 | 41 | /** 42 | * Reverse the migrations. 43 | */ 44 | public function down(): void 45 | { 46 | Schema::dropIfExists('users'); 47 | Schema::dropIfExists('password_reset_tokens'); 48 | Schema::dropIfExists('sessions'); 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /tests/Pest.php: -------------------------------------------------------------------------------- 1 | in('Feature'); 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Expectations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | When you're writing tests, you often need to check that values meet certain conditions. The 25 | | "expect()" function gives you access to a set of "expectations" methods that you can use 26 | | to assert different things. Of course, you may extend the Expectation API at any time. 27 | | 28 | */ 29 | 30 | expect()->extend('toBeOne', function () { 31 | return $this->toBe(1); 32 | }); 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Functions 37 | |-------------------------------------------------------------------------- 38 | | 39 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your 40 | | project that you don't want to repeat in every file. Here you can also expose helpers as 41 | | global functions to help you to reduce the number of lines of code in your test files. 42 | | 43 | */ 44 | 45 | function something() 46 | { 47 | // .. 48 | } 49 | -------------------------------------------------------------------------------- /app/Http/Controllers/ProfileController.php: -------------------------------------------------------------------------------- 1 | $request->user() instanceof MustVerifyEmail, 23 | 'status' => session('status'), 24 | ]); 25 | } 26 | 27 | /** 28 | * Update the user's profile information. 29 | */ 30 | public function update(ProfileUpdateRequest $request): RedirectResponse 31 | { 32 | $request->user()->fill($request->validated()); 33 | 34 | if ($request->user()->isDirty('email')) { 35 | $request->user()->email_verified_at = null; 36 | } 37 | 38 | $request->user()->save(); 39 | 40 | return Redirect::route('profile.edit'); 41 | } 42 | 43 | /** 44 | * Delete the user's account. 45 | */ 46 | public function destroy(Request $request): RedirectResponse 47 | { 48 | $request->validate([ 49 | 'password' => ['required', 'current_password'], 50 | ]); 51 | 52 | $user = $request->user(); 53 | 54 | Auth::logout(); 55 | 56 | $user->delete(); 57 | 58 | $request->session()->invalidate(); 59 | $request->session()->regenerateToken(); 60 | 61 | return Redirect::to('/'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | get('/forgot-password'); 9 | 10 | $response->assertStatus(200); 11 | }); 12 | 13 | test('reset password link can be requested', function () { 14 | Notification::fake(); 15 | 16 | $user = User::factory()->create(); 17 | 18 | $this->post('/forgot-password', ['email' => $user->email]); 19 | 20 | Notification::assertSentTo($user, ResetPassword::class); 21 | }); 22 | 23 | test('reset password screen can be rendered', function () { 24 | Notification::fake(); 25 | 26 | $user = User::factory()->create(); 27 | 28 | $this->post('/forgot-password', ['email' => $user->email]); 29 | 30 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) { 31 | $response = $this->get('/reset-password/'.$notification->token); 32 | 33 | $response->assertStatus(200); 34 | 35 | return true; 36 | }); 37 | }); 38 | 39 | test('password can be reset with valid token', function () { 40 | Notification::fake(); 41 | 42 | $user = User::factory()->create(); 43 | 44 | $this->post('/forgot-password', ['email' => $user->email]); 45 | 46 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { 47 | $response = $this->post('/reset-password', [ 48 | 'token' => $notification->token, 49 | 'email' => $user->email, 50 | 'password' => 'password', 51 | 'password_confirmation' => 'password', 52 | ]); 53 | 54 | $response 55 | ->assertSessionHasNoErrors() 56 | ->assertRedirect(route('login')); 57 | 58 | return true; 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /database/seeders/ArticleSeeder.php: -------------------------------------------------------------------------------- 1 | get(); 27 | 28 | foreach ($editors as $editor) { 29 | for ($i = 0; $i < 20; $i++) { 30 | if (empty($unique_pics)) { 31 | throw new \Exception('Ran out of unique images.'); 32 | } 33 | 34 | $article = Article::factory()->make([ 35 | 'article_image' => array_shift($unique_pics), 36 | 'user_id' => $editor->id, 37 | ]); 38 | 39 | $article->save(); 40 | } 41 | } 42 | 43 | $chiefs = User::where('role', 'chief-editor')->get(); 44 | foreach ($chiefs as $chief) { 45 | for ($i = 0; $i < 10; $i++) { 46 | if (empty($unique_pics)) { 47 | throw new \Exception('Ran out of unique images.'); 48 | } 49 | 50 | $article = Article::factory()->make([ 51 | 'article_image' => array_shift($unique_pics), 52 | 'user_id' => $chief->id, 53 | ]); 54 | 55 | $article->save(); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/VerifyEmail.jsx: -------------------------------------------------------------------------------- 1 | import GuestLayout from '@/Layouts/GuestLayout'; 2 | import PrimaryButton from '@/Components/PrimaryButton'; 3 | import { Head, Link, useForm } from '@inertiajs/react'; 4 | 5 | export default function VerifyEmail({ status }) { 6 | const { post, processing } = useForm({}); 7 | 8 | const submit = (e) => { 9 | e.preventDefault(); 10 | 11 | post(route('verification.send')); 12 | }; 13 | 14 | return ( 15 | 16 | 17 | 18 |
19 | Thanks for signing up! Before getting started, could you verify your email address by clicking on the 20 | link we just emailed to you? If you didn't receive the email, we will gladly send you another. 21 |
22 | 23 | {status === 'verification-link-sent' && ( 24 |
25 | A new verification link has been sent to the email address you provided during registration. 26 |
27 | )} 28 | 29 |
30 |
31 | Resend Verification Email 32 | 33 | 39 | Log Out 40 | 41 |
42 |
43 |
44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ForgotPassword.jsx: -------------------------------------------------------------------------------- 1 | import GuestLayout from '@/Layouts/GuestLayout'; 2 | import InputError from '@/Components/InputError'; 3 | import PrimaryButton from '@/Components/PrimaryButton'; 4 | import TextInput from '@/Components/TextInput'; 5 | import { Head, useForm } from '@inertiajs/react'; 6 | 7 | export default function ForgotPassword({ status }) { 8 | const { data, setData, post, processing, errors } = useForm({ 9 | email: '', 10 | }); 11 | 12 | const submit = (e) => { 13 | e.preventDefault(); 14 | 15 | post(route('password.email')); 16 | }; 17 | 18 | return ( 19 | 20 | 21 | 22 |
23 | Forgot your password? No problem. Just let us know your email address and we will email you a password 24 | reset link that will allow you to choose a new one. 25 |
26 | 27 | {status &&
{status}
} 28 | 29 |
30 | setData('email', e.target.value)} 38 | /> 39 | 40 | 41 | 42 |
43 | 44 | Email Password Reset Link 45 | 46 |
47 | 48 |
49 | ); 50 | } 51 | -------------------------------------------------------------------------------- /database/migrations/0001_01_01_000002_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('queue')->index(); 17 | $table->longText('payload'); 18 | $table->unsignedTinyInteger('attempts'); 19 | $table->unsignedInteger('reserved_at')->nullable(); 20 | $table->unsignedInteger('available_at'); 21 | $table->unsignedInteger('created_at'); 22 | }); 23 | 24 | Schema::create('job_batches', function (Blueprint $table) { 25 | $table->string('id')->primary(); 26 | $table->string('name'); 27 | $table->integer('total_jobs'); 28 | $table->integer('pending_jobs'); 29 | $table->integer('failed_jobs'); 30 | $table->longText('failed_job_ids'); 31 | $table->mediumText('options')->nullable(); 32 | $table->integer('cancelled_at')->nullable(); 33 | $table->integer('created_at'); 34 | $table->integer('finished_at')->nullable(); 35 | }); 36 | 37 | Schema::create('failed_jobs', function (Blueprint $table) { 38 | $table->id(); 39 | $table->string('uuid')->unique(); 40 | $table->text('connection'); 41 | $table->text('queue'); 42 | $table->longText('payload'); 43 | $table->longText('exception'); 44 | $table->timestamp('failed_at')->useCurrent(); 45 | }); 46 | } 47 | 48 | /** 49 | * Reverse the migrations. 50 | */ 51 | public function down(): void 52 | { 53 | Schema::dropIfExists('jobs'); 54 | Schema::dropIfExists('job_batches'); 55 | Schema::dropIfExists('failed_jobs'); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ConfirmPassword.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import GuestLayout from '@/Layouts/GuestLayout'; 3 | import InputError from '@/Components/InputError'; 4 | import InputLabel from '@/Components/InputLabel'; 5 | import PrimaryButton from '@/Components/PrimaryButton'; 6 | import TextInput from '@/Components/TextInput'; 7 | import { Head, useForm } from '@inertiajs/react'; 8 | 9 | export default function ConfirmPassword() { 10 | const { data, setData, post, processing, errors, reset } = useForm({ 11 | password: '', 12 | }); 13 | 14 | useEffect(() => { 15 | return () => { 16 | reset('password'); 17 | }; 18 | }, []); 19 | 20 | const submit = (e) => { 21 | e.preventDefault(); 22 | 23 | post(route('password.confirm')); 24 | }; 25 | 26 | return ( 27 | 28 | 29 | 30 |
31 | This is a secure area of the application. Please confirm your password before continuing. 32 |
33 | 34 |
35 |
36 | 37 | 38 | setData('password', e.target.value)} 46 | /> 47 | 48 | 49 |
50 | 51 |
52 | 53 | Confirm 54 | 55 |
56 |
57 |
58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /resources/js/Components/Modal.jsx: -------------------------------------------------------------------------------- 1 | import { Fragment } from 'react'; 2 | import { Dialog, Transition } from '@headlessui/react'; 3 | 4 | export default function Modal({ children, show = false, maxWidth = '2xl', closeable = true, onClose = () => {} }) { 5 | const close = () => { 6 | if (closeable) { 7 | onClose(); 8 | } 9 | }; 10 | 11 | const maxWidthClass = { 12 | sm: 'sm:max-w-sm', 13 | md: 'sm:max-w-md', 14 | lg: 'sm:max-w-lg', 15 | xl: 'sm:max-w-xl', 16 | '2xl': 'sm:max-w-2xl', 17 | }[maxWidth]; 18 | 19 | return ( 20 | 21 | 27 | 36 |
37 | 38 | 39 | 48 | 51 | {children} 52 | 53 | 54 |
55 |
56 | ); 57 | } 58 | -------------------------------------------------------------------------------- /tests/Feature/ProfileTest.php: -------------------------------------------------------------------------------- 1 | create(); 7 | 8 | $response = $this 9 | ->actingAs($user) 10 | ->get('/profile'); 11 | 12 | $response->assertOk(); 13 | }); 14 | 15 | test('profile information can be updated', function () { 16 | $user = User::factory()->create(); 17 | 18 | $response = $this 19 | ->actingAs($user) 20 | ->patch('/profile', [ 21 | 'name' => 'Test User', 22 | 'email' => 'test@example.com', 23 | ]); 24 | 25 | $response 26 | ->assertSessionHasNoErrors() 27 | ->assertRedirect('/profile'); 28 | 29 | $user->refresh(); 30 | 31 | $this->assertSame('Test User', $user->name); 32 | $this->assertSame('test@example.com', $user->email); 33 | $this->assertNull($user->email_verified_at); 34 | }); 35 | 36 | test('email verification status is unchanged when the email address is unchanged', function () { 37 | $user = User::factory()->create(); 38 | 39 | $response = $this 40 | ->actingAs($user) 41 | ->patch('/profile', [ 42 | 'name' => 'Test User', 43 | 'email' => $user->email, 44 | ]); 45 | 46 | $response 47 | ->assertSessionHasNoErrors() 48 | ->assertRedirect('/profile'); 49 | 50 | $this->assertNotNull($user->refresh()->email_verified_at); 51 | }); 52 | 53 | test('user can delete their account', function () { 54 | $user = User::factory()->create(); 55 | 56 | $response = $this 57 | ->actingAs($user) 58 | ->delete('/profile', [ 59 | 'password' => 'password', 60 | ]); 61 | 62 | $response 63 | ->assertSessionHasNoErrors() 64 | ->assertRedirect('/'); 65 | 66 | $this->assertGuest(); 67 | $this->assertNull($user->fresh()); 68 | }); 69 | 70 | test('correct password must be provided to delete account', function () { 71 | $user = User::factory()->create(); 72 | 73 | $response = $this 74 | ->actingAs($user) 75 | ->from('/profile') 76 | ->delete('/profile', [ 77 | 'password' => 'wrong-password', 78 | ]); 79 | 80 | $response 81 | ->assertSessionHasErrors('password') 82 | ->assertRedirect('/profile'); 83 | 84 | $this->assertNotNull($user->fresh()); 85 | }); 86 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The skeleton application for the Laravel framework.", 5 | "keywords": ["laravel", "framework"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^8.2", 9 | "inertiajs/inertia-laravel": "^1.0", 10 | "laravel/framework": "^11.0", 11 | "laravel/reverb": "@beta", 12 | "laravel/sanctum": "^4.0", 13 | "laravel/tinker": "^2.9", 14 | "tightenco/ziggy": "^2.0" 15 | }, 16 | "require-dev": { 17 | "fakerphp/faker": "^1.23", 18 | "laravel/breeze": "^2.0", 19 | "laravel/pint": "^1.13", 20 | "laravel/sail": "^1.26", 21 | "mockery/mockery": "^1.6", 22 | "nunomaduro/collision": "^8.0", 23 | "pestphp/pest": "^2.0", 24 | "pestphp/pest-plugin-laravel": "^2.0", 25 | "spatie/laravel-ignition": "^2.4" 26 | }, 27 | "autoload": { 28 | "psr-4": { 29 | "App\\": "app/", 30 | "Database\\Factories\\": "database/factories/", 31 | "Database\\Seeders\\": "database/seeders/" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "Tests\\": "tests/" 37 | } 38 | }, 39 | "scripts": { 40 | "post-autoload-dump": [ 41 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 42 | "@php artisan package:discover --ansi" 43 | ], 44 | "post-update-cmd": [ 45 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 46 | ], 47 | "post-root-package-install": [ 48 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 49 | ], 50 | "post-create-project-cmd": [ 51 | "@php artisan key:generate --ansi", 52 | "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"", 53 | "@php artisan migrate --graceful --ansi" 54 | ] 55 | }, 56 | "extra": { 57 | "laravel": { 58 | "dont-discover": [] 59 | } 60 | }, 61 | "config": { 62 | "optimize-autoloader": true, 63 | "preferred-install": "dist", 64 | "sort-packages": true, 65 | "allow-plugins": { 66 | "pestphp/pest-plugin": true, 67 | "php-http/discovery": true 68 | } 69 | }, 70 | "minimum-stability": "stable", 71 | "prefer-stable": true 72 | } 73 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | state(['role' => 'editor']) 33 | ->create(); 34 | 35 | // Step 3: Fetch all editors 36 | $editors = User::where('role', 'editor')->get(); 37 | 38 | // Step 4: Create 20 articles by editors, assign unique images from the images array. 39 | foreach ($editors as $editor) { 40 | for ($i = 0; $i < 20; $i++) { 41 | if (empty($unique_pics)) { 42 | throw new \Exception('Ran out of unique images.'); 43 | } 44 | 45 | $article = Article::factory()->make([ 46 | 'article_image' => array_shift($unique_pics), 47 | 'user_id' => $editor->id, 48 | ]); 49 | 50 | $article->save(); 51 | } 52 | } 53 | 54 | // Step 5: Create one 'Chief Editor' user and ten articles for the user. 55 | User::factory() 56 | ->state(['role' => 'chief-editor']) 57 | ->create(); 58 | 59 | $chiefs = User::where('role', 'chief-editor')->get(); 60 | foreach ($chiefs as $chief) { 61 | for ($i = 0; $i < 10; $i++) { 62 | if (empty($unique_pics)) { 63 | throw new \Exception('Ran out of unique images.'); 64 | } 65 | 66 | $article = Article::factory()->make([ 67 | 'article_image' => array_shift($unique_pics), 68 | 'user_id' => $chief->id, 69 | ]); 70 | 71 | $article->save(); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /routes/auth.php: -------------------------------------------------------------------------------- 1 | group(function () { 15 | Route::get('register', [RegisteredUserController::class, 'create']) 16 | ->name('register'); 17 | 18 | Route::post('register', [RegisteredUserController::class, 'store']); 19 | 20 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 21 | ->name('login'); 22 | 23 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 24 | 25 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) 26 | ->name('password.request'); 27 | 28 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) 29 | ->name('password.email'); 30 | 31 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) 32 | ->name('password.reset'); 33 | 34 | Route::post('reset-password', [NewPasswordController::class, 'store']) 35 | ->name('password.store'); 36 | }); 37 | 38 | Route::middleware('auth')->group(function () { 39 | Route::get('verify-email', EmailVerificationPromptController::class) 40 | ->name('verification.notice'); 41 | 42 | Route::get('verify-email/{id}/{hash}', VerifyEmailController::class) 43 | ->middleware(['signed', 'throttle:6,1']) 44 | ->name('verification.verify'); 45 | 46 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) 47 | ->middleware('throttle:6,1') 48 | ->name('verification.send'); 49 | 50 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) 51 | ->name('password.confirm'); 52 | 53 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); 54 | 55 | Route::put('password', [PasswordController::class, 'update'])->name('password.update'); 56 | 57 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 58 | ->name('logout'); 59 | }); 60 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'email' => ['required', 'string', 'email'], 31 | 'password' => ['required', 'string'], 32 | ]; 33 | } 34 | 35 | /** 36 | * Attempt to authenticate the request's credentials. 37 | * 38 | * @throws \Illuminate\Validation\ValidationException 39 | */ 40 | public function authenticate(): void 41 | { 42 | $this->ensureIsNotRateLimited(); 43 | 44 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 45 | RateLimiter::hit($this->throttleKey()); 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => trans('auth.failed'), 49 | ]); 50 | } 51 | 52 | RateLimiter::clear($this->throttleKey()); 53 | } 54 | 55 | /** 56 | * Ensure the login request is not rate limited. 57 | * 58 | * @throws \Illuminate\Validation\ValidationException 59 | */ 60 | public function ensureIsNotRateLimited(): void 61 | { 62 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 63 | return; 64 | } 65 | 66 | event(new Lockout($this)); 67 | 68 | $seconds = RateLimiter::availableIn($this->throttleKey()); 69 | 70 | throw ValidationException::withMessages([ 71 | 'email' => trans('auth.throttle', [ 72 | 'seconds' => $seconds, 73 | 'minutes' => ceil($seconds / 60), 74 | ]), 75 | ]); 76 | } 77 | 78 | /** 79 | * Get the rate limiting throttle key for the request. 80 | */ 81 | public function throttleKey(): string 82 | { 83 | return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/NewPasswordController.php: -------------------------------------------------------------------------------- 1 | $request->email, 26 | 'token' => $request->route('token'), 27 | ]); 28 | } 29 | 30 | /** 31 | * Handle an incoming new password request. 32 | * 33 | * @throws \Illuminate\Validation\ValidationException 34 | */ 35 | public function store(Request $request): RedirectResponse 36 | { 37 | $request->validate([ 38 | 'token' => 'required', 39 | 'email' => 'required|email', 40 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 41 | ]); 42 | 43 | // Here we will attempt to reset the user's password. If it is successful we 44 | // will update the password on an actual user model and persist it to the 45 | // database. Otherwise we will parse the error and return the response. 46 | $status = Password::reset( 47 | $request->only('email', 'password', 'password_confirmation', 'token'), 48 | function ($user) use ($request) { 49 | $user->forceFill([ 50 | 'password' => Hash::make($request->password), 51 | 'remember_token' => Str::random(60), 52 | ])->save(); 53 | 54 | event(new PasswordReset($user)); 55 | } 56 | ); 57 | 58 | // If the password was successfully reset, we will redirect the user back to 59 | // the application's home authenticated view. If there is an error we can 60 | // redirect them back to where they came from with their error message. 61 | if ($status == Password::PASSWORD_RESET) { 62 | return redirect()->route('login')->with('status', __($status)); 63 | } 64 | 65 | throw ValidationException::withMessages([ 66 | 'email' => [trans($status)], 67 | ]); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_CONNECTION', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over WebSockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'reverb' => [ 34 | 'driver' => 'reverb', 35 | 'key' => env('REVERB_APP_KEY'), 36 | 'secret' => env('REVERB_APP_SECRET'), 37 | 'app_id' => env('REVERB_APP_ID'), 38 | 'options' => [ 39 | 'host' => env('REVERB_HOST'), 40 | 'port' => env('REVERB_PORT', 443), 41 | 'scheme' => env('REVERB_SCHEME', 'https'), 42 | 'useTLS' => env('REVERB_SCHEME', 'https') === 'https', 43 | ], 44 | 'client_options' => [ 45 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 46 | ], 47 | ], 48 | 49 | 'pusher' => [ 50 | 'driver' => 'pusher', 51 | 'key' => env('PUSHER_APP_KEY'), 52 | 'secret' => env('PUSHER_APP_SECRET'), 53 | 'app_id' => env('PUSHER_APP_ID'), 54 | 'options' => [ 55 | 'cluster' => env('PUSHER_APP_CLUSTER'), 56 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 57 | 'port' => env('PUSHER_PORT', 443), 58 | 'scheme' => env('PUSHER_SCHEME', 'https'), 59 | 'encrypted' => true, 60 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 61 | ], 62 | 'client_options' => [ 63 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 64 | ], 65 | ], 66 | 67 | 'ably' => [ 68 | 'driver' => 'ably', 69 | 'key' => env('ABLY_KEY'), 70 | ], 71 | 72 | 'log' => [ 73 | 'driver' => 'log', 74 | ], 75 | 76 | 'null' => [ 77 | 'driver' => 'null', 78 | ], 79 | 80 | ], 81 | 82 | ]; 83 | -------------------------------------------------------------------------------- /resources/js/Components/ApplicationLogo.jsx: -------------------------------------------------------------------------------- 1 | export default function ApplicationLogo(props) { 2 | return ( 3 | 4 | 5 | 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /resources/js/Components/Dropdown.jsx: -------------------------------------------------------------------------------- 1 | import { useState, createContext, useContext, Fragment } from 'react'; 2 | import { Link } from '@inertiajs/react'; 3 | import { Transition } from '@headlessui/react'; 4 | 5 | const DropDownContext = createContext(); 6 | 7 | const Dropdown = ({ children }) => { 8 | const [open, setOpen] = useState(false); 9 | 10 | const toggleOpen = () => { 11 | setOpen((previousState) => !previousState); 12 | }; 13 | 14 | return ( 15 | 16 |
{children}
17 |
18 | ); 19 | }; 20 | 21 | const Trigger = ({ children }) => { 22 | const { open, setOpen, toggleOpen } = useContext(DropDownContext); 23 | 24 | return ( 25 | <> 26 |
{children}
27 | 28 | {open &&
setOpen(false)}>
} 29 | 30 | ); 31 | }; 32 | 33 | const Content = ({ align = 'right', width = '48', contentClasses = 'py-1 bg-white', children }) => { 34 | const { open, setOpen } = useContext(DropDownContext); 35 | 36 | let alignmentClasses = 'origin-top'; 37 | 38 | if (align === 'left') { 39 | alignmentClasses = 'ltr:origin-top-left rtl:origin-top-right start-0'; 40 | } else if (align === 'right') { 41 | alignmentClasses = 'ltr:origin-top-right rtl:origin-top-left end-0'; 42 | } 43 | 44 | let widthClasses = ''; 45 | 46 | if (width === '48') { 47 | widthClasses = 'w-48'; 48 | } 49 | 50 | return ( 51 | <> 52 | 62 |
setOpen(false)} 65 | > 66 |
{children}
67 |
68 |
69 | 70 | ); 71 | }; 72 | 73 | const DropdownLink = ({ className = '', children, ...props }) => { 74 | return ( 75 | 82 | {children} 83 | 84 | ); 85 | }; 86 | 87 | Dropdown.Trigger = Trigger; 88 | Dropdown.Content = Content; 89 | Dropdown.Link = DropdownLink; 90 | 91 | export default Dropdown; 92 | -------------------------------------------------------------------------------- /resources/js/Components/Notification.jsx: -------------------------------------------------------------------------------- 1 | import { Button, Card, CardHeader, CardBody } from '@nextui-org/react' 2 | import { useEffect, useState } from 'react' 3 | import { motion } from 'framer-motion' 4 | 5 | const Notification = ({ article, closeNotif }) => { 6 | const [timeoutId, setTimeoutId] = useState(null) 7 | const duration = 5000 8 | 9 | useEffect(() => { 10 | // Clear any existing timeout 11 | if (timeoutId) { 12 | clearTimeout(timeoutId) 13 | } 14 | // Start a new timeout 15 | const newTimeoutId = setTimeout(() => { 16 | closeNotif(article) 17 | }, duration) 18 | 19 | setTimeoutId(newTimeoutId) 20 | 21 | return () => { 22 | if (timeoutId) { 23 | clearTimeout(timeoutId) 24 | } 25 | } 26 | }, []) 27 | 28 | // Stop the timer on mouse enter 29 | const handleMouseEnter = () => { 30 | if (timeoutId) { 31 | clearTimeout(timeoutId) 32 | } 33 | } 34 | 35 | // Restart the timer after mouse leave 36 | const handleMouseLeave = () => { 37 | const newTimeoutId = setTimeout(() => { 38 | closeNotif(article) 39 | }, duration) 40 | 41 | setTimeoutId(newTimeoutId) 42 | } 43 | 44 | return ( 45 | 51 | 52 |
53 |
54 |

55 | Delete request was sent 56 |

57 |
58 |
59 | 84 |
85 | 86 |

You requested to delete the following article:

87 |

{article.title}

88 |

89 | The chief editor must approve this before the removal is 90 | finalized. 91 |

92 |
93 |
94 | ) 95 | } 96 | 97 | export default Notification 98 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ResetPassword.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import GuestLayout from '@/Layouts/GuestLayout'; 3 | import InputError from '@/Components/InputError'; 4 | import InputLabel from '@/Components/InputLabel'; 5 | import PrimaryButton from '@/Components/PrimaryButton'; 6 | import TextInput from '@/Components/TextInput'; 7 | import { Head, useForm } from '@inertiajs/react'; 8 | 9 | export default function ResetPassword({ token, email }) { 10 | const { data, setData, post, processing, errors, reset } = useForm({ 11 | token: token, 12 | email: email, 13 | password: '', 14 | password_confirmation: '', 15 | }); 16 | 17 | useEffect(() => { 18 | return () => { 19 | reset('password', 'password_confirmation'); 20 | }; 21 | }, []); 22 | 23 | const submit = (e) => { 24 | e.preventDefault(); 25 | 26 | post(route('password.store')); 27 | }; 28 | 29 | return ( 30 | 31 | 32 | 33 |
34 |
35 | 36 | 37 | setData('email', e.target.value)} 45 | /> 46 | 47 | 48 |
49 | 50 |
51 | 52 | 53 | setData('password', e.target.value)} 62 | /> 63 | 64 | 65 |
66 | 67 |
68 | 69 | 70 | setData('password_confirmation', e.target.value)} 78 | /> 79 | 80 | 81 |
82 | 83 |
84 | 85 | Reset Password 86 | 87 |
88 |
89 |
90 | ); 91 | } 92 | -------------------------------------------------------------------------------- /config/reverb.php: -------------------------------------------------------------------------------- 1 | env('REVERB_SERVER', 'reverb'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Reverb Servers 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define details for each of the supported Reverb servers. 24 | | Each server has its own configuration options that are defined in 25 | | the array below. You should ensure all the options are present. 26 | | 27 | */ 28 | 29 | 'servers' => [ 30 | 31 | 'reverb' => [ 32 | 'host' => env('REVERB_SERVER_HOST', '0.0.0.0'), 33 | 'port' => env('REVERB_SERVER_PORT', 8080), 34 | 'hostname' => env('REVERB_HOST'), 35 | 'options' => [ 36 | 'tls' => [], 37 | ], 38 | 'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000), 39 | 'scaling' => [ 40 | 'enabled' => env('REVERB_SCALING_ENABLED', false), 41 | 'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'), 42 | 'server' => [ 43 | 'url' => env('REDIS_URL'), 44 | 'host' => env('REDIS_HOST', '127.0.0.1'), 45 | 'port' => env('REDIS_PORT', '6379'), 46 | 'username' => env('REDIS_USERNAME'), 47 | 'password' => env('REDIS_PASSWORD'), 48 | 'database' => env('REDIS_DB', '0'), 49 | ], 50 | ], 51 | 'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15), 52 | 'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15), 53 | ], 54 | 55 | ], 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Reverb Applications 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may define how Reverb applications are managed. If you choose 63 | | to use the "config" provider, you may define an array of apps which 64 | | your server will support, including their connection credentials. 65 | | 66 | */ 67 | 68 | 'apps' => [ 69 | 70 | 'provider' => 'config', 71 | 72 | 'apps' => [ 73 | [ 74 | 'key' => env('REVERB_APP_KEY'), 75 | 'secret' => env('REVERB_APP_SECRET'), 76 | 'app_id' => env('REVERB_APP_ID'), 77 | 'options' => [ 78 | 'host' => env('REVERB_HOST'), 79 | 'port' => env('REVERB_PORT', 443), 80 | 'scheme' => env('REVERB_SCHEME', 'https'), 81 | 'useTLS' => env('REVERB_SCHEME', 'https') === 'https', 82 | ], 83 | 'allowed_origins' => ['*'], 84 | 'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60), 85 | 'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000), 86 | ], 87 | ], 88 | 89 | ], 90 | 91 | ]; 92 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/Login.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import Checkbox from '@/Components/Checkbox'; 3 | import GuestLayout from '@/Layouts/GuestLayout'; 4 | import InputError from '@/Components/InputError'; 5 | import InputLabel from '@/Components/InputLabel'; 6 | import PrimaryButton from '@/Components/PrimaryButton'; 7 | import TextInput from '@/Components/TextInput'; 8 | import { Head, Link, useForm } from '@inertiajs/react'; 9 | 10 | export default function Login({ status, canResetPassword }) { 11 | const { data, setData, post, processing, errors, reset } = useForm({ 12 | email: '', 13 | password: '', 14 | remember: false, 15 | }); 16 | 17 | useEffect(() => { 18 | return () => { 19 | reset('password'); 20 | }; 21 | }, []); 22 | 23 | const submit = (e) => { 24 | e.preventDefault(); 25 | 26 | post(route('login')); 27 | }; 28 | 29 | return ( 30 | 31 | 32 | 33 | {status &&
{status}
} 34 | 35 |
36 |
37 | 38 | 39 | setData('email', e.target.value)} 48 | /> 49 | 50 | 51 |
52 | 53 |
54 | 55 | 56 | setData('password', e.target.value)} 64 | /> 65 | 66 | 67 |
68 | 69 |
70 | 78 |
79 | 80 |
81 | {canResetPassword && ( 82 | 86 | Forgot your password? 87 | 88 | )} 89 | 90 | 91 | Log in 92 | 93 |
94 |
95 |
96 | ); 97 | } 98 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_STORE', 'database'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "array", "database", "file", "memcached", 30 | | "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'array' => [ 37 | 'driver' => 'array', 38 | 'serialize' => false, 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => env('DB_CACHE_TABLE', 'cache'), 44 | 'connection' => env('DB_CACHE_CONNECTION'), 45 | 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), 46 | ], 47 | 48 | 'file' => [ 49 | 'driver' => 'file', 50 | 'path' => storage_path('framework/cache/data'), 51 | 'lock_path' => storage_path('framework/cache/data'), 52 | ], 53 | 54 | 'memcached' => [ 55 | 'driver' => 'memcached', 56 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 57 | 'sasl' => [ 58 | env('MEMCACHED_USERNAME'), 59 | env('MEMCACHED_PASSWORD'), 60 | ], 61 | 'options' => [ 62 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 63 | ], 64 | 'servers' => [ 65 | [ 66 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 67 | 'port' => env('MEMCACHED_PORT', 11211), 68 | 'weight' => 100, 69 | ], 70 | ], 71 | ], 72 | 73 | 'redis' => [ 74 | 'driver' => 'redis', 75 | 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), 76 | 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 77 | ], 78 | 79 | 'dynamodb' => [ 80 | 'driver' => 'dynamodb', 81 | 'key' => env('AWS_ACCESS_KEY_ID'), 82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 85 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 86 | ], 87 | 88 | 'octane' => [ 89 | 'driver' => 'octane', 90 | ], 91 | 92 | ], 93 | 94 | /* 95 | |-------------------------------------------------------------------------- 96 | | Cache Key Prefix 97 | |-------------------------------------------------------------------------- 98 | | 99 | | When utilizing the APC, database, memcached, Redis, and DynamoDB cache 100 | | stores, there might be other applications using the same cache. For 101 | | that reason, you may prefix every cache key to avoid collisions. 102 | | 103 | */ 104 | 105 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 106 | 107 | ]; 108 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Partials/DeleteUserForm.jsx: -------------------------------------------------------------------------------- 1 | import { useRef, useState } from 'react'; 2 | import DangerButton from '@/Components/DangerButton'; 3 | import InputError from '@/Components/InputError'; 4 | import InputLabel from '@/Components/InputLabel'; 5 | import Modal from '@/Components/Modal'; 6 | import SecondaryButton from '@/Components/SecondaryButton'; 7 | import TextInput from '@/Components/TextInput'; 8 | import { useForm } from '@inertiajs/react'; 9 | 10 | export default function DeleteUserForm({ className = '' }) { 11 | const [confirmingUserDeletion, setConfirmingUserDeletion] = useState(false); 12 | const passwordInput = useRef(); 13 | 14 | const { 15 | data, 16 | setData, 17 | delete: destroy, 18 | processing, 19 | reset, 20 | errors, 21 | } = useForm({ 22 | password: '', 23 | }); 24 | 25 | const confirmUserDeletion = () => { 26 | setConfirmingUserDeletion(true); 27 | }; 28 | 29 | const deleteUser = (e) => { 30 | e.preventDefault(); 31 | 32 | destroy(route('profile.destroy'), { 33 | preserveScroll: true, 34 | onSuccess: () => closeModal(), 35 | onError: () => passwordInput.current.focus(), 36 | onFinish: () => reset(), 37 | }); 38 | }; 39 | 40 | const closeModal = () => { 41 | setConfirmingUserDeletion(false); 42 | 43 | reset(); 44 | }; 45 | 46 | return ( 47 |
48 |
49 |

Delete Account

50 | 51 |

52 | Once your account is deleted, all of its resources and data will be permanently deleted. Before 53 | deleting your account, please download any data or information that you wish to retain. 54 |

55 |
56 | 57 | Delete Account 58 | 59 | 60 |
61 |

62 | Are you sure you want to delete your account? 63 |

64 | 65 |

66 | Once your account is deleted, all of its resources and data will be permanently deleted. Please 67 | enter your password to confirm you would like to permanently delete your account. 68 |

69 | 70 |
71 | 72 | 73 | setData('password', e.target.value)} 80 | className="mt-1 block w-3/4" 81 | isFocused 82 | placeholder="Password" 83 | /> 84 | 85 | 86 |
87 | 88 |
89 | Cancel 90 | 91 | 92 | Delete Account 93 | 94 |
95 |
96 |
97 |
98 | ); 99 | } 100 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'log'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Mailer Configurations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may configure all of the mailers used by your application plus 25 | | their respective settings. Several examples have been configured for 26 | | you and you are free to add your own as your application requires. 27 | | 28 | | Laravel supports a variety of mail "transport" drivers that can be used 29 | | when delivering an email. You may specify which one you're using for 30 | | your mailers below. You may also add additional mailers if needed. 31 | | 32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 33 | | "postmark", "resend", "log", "array", 34 | | "failover", "roundrobin" 35 | | 36 | */ 37 | 38 | 'mailers' => [ 39 | 40 | 'smtp' => [ 41 | 'transport' => 'smtp', 42 | 'url' => env('MAIL_URL'), 43 | 'host' => env('MAIL_HOST', '127.0.0.1'), 44 | 'port' => env('MAIL_PORT', 2525), 45 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 46 | 'username' => env('MAIL_USERNAME'), 47 | 'password' => env('MAIL_PASSWORD'), 48 | 'timeout' => null, 49 | 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), 50 | ], 51 | 52 | 'ses' => [ 53 | 'transport' => 'ses', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), 59 | // 'client' => [ 60 | // 'timeout' => 5, 61 | // ], 62 | ], 63 | 64 | 'resend' => [ 65 | 'transport' => 'resend', 66 | ], 67 | 68 | 'sendmail' => [ 69 | 'transport' => 'sendmail', 70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 71 | ], 72 | 73 | 'log' => [ 74 | 'transport' => 'log', 75 | 'channel' => env('MAIL_LOG_CHANNEL'), 76 | ], 77 | 78 | 'array' => [ 79 | 'transport' => 'array', 80 | ], 81 | 82 | 'failover' => [ 83 | 'transport' => 'failover', 84 | 'mailers' => [ 85 | 'smtp', 86 | 'log', 87 | ], 88 | ], 89 | 90 | 'roundrobin' => [ 91 | 'transport' => 'roundrobin', 92 | 'mailers' => [ 93 | 'ses', 94 | 'postmark', 95 | ], 96 | ], 97 | 98 | ], 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Global "From" Address 103 | |-------------------------------------------------------------------------- 104 | | 105 | | You may wish for all emails sent by your application to be sent from 106 | | the same address. Here you may specify a name and address that is 107 | | used globally for all emails that are sent by your application. 108 | | 109 | */ 110 | 111 | 'from' => [ 112 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 113 | 'name' => env('MAIL_FROM_NAME', 'Example'), 114 | ], 115 | 116 | ]; 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Laravel Logo

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | ## About Laravel 11 | 12 | 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: 13 | 14 | - [Simple, fast routing engine](https://laravel.com/docs/routing). 15 | - [Powerful dependency injection container](https://laravel.com/docs/container). 16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. 17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). 18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations). 19 | - [Robust background job processing](https://laravel.com/docs/queues). 20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). 21 | 22 | Laravel is accessible, powerful, and provides tools required for large, robust applications. 23 | 24 | ## Learning Laravel 25 | 26 | 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. 27 | 28 | You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. 29 | 30 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of 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. 31 | 32 | ## Laravel Sponsors 33 | 34 | 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 Partners program](https://partners.laravel.com). 35 | 36 | ### Premium Partners 37 | 38 | - **[Vehikl](https://vehikl.com/)** 39 | - **[Tighten Co.](https://tighten.co)** 40 | - **[WebReinvent](https://webreinvent.com/)** 41 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** 42 | - **[64 Robots](https://64robots.com)** 43 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** 44 | - **[Cyber-Duck](https://cyber-duck.co.uk)** 45 | - **[DevSquad](https://devsquad.com/hire-laravel-developers)** 46 | - **[Jump24](https://jump24.co.uk)** 47 | - **[Redberry](https://redberry.international/laravel/)** 48 | - **[Active Logic](https://activelogic.com)** 49 | - **[byte5](https://byte5.de)** 50 | - **[OP.GG](https://op.gg)** 51 | 52 | ## Contributing 53 | 54 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). 55 | 56 | ## Code of Conduct 57 | 58 | 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). 59 | 60 | ## Security Vulnerabilities 61 | 62 | 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. 63 | 64 | ## License 65 | 66 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 67 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'database'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection options for every queue backend 24 | | used by your application. An example configuration is provided for 25 | | each backend supported by Laravel. You're also free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'connection' => env('DB_QUEUE_CONNECTION'), 40 | 'table' => env('DB_QUEUE_TABLE', 'jobs'), 41 | 'queue' => env('DB_QUEUE', 'default'), 42 | 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), 43 | 'after_commit' => false, 44 | ], 45 | 46 | 'beanstalkd' => [ 47 | 'driver' => 'beanstalkd', 48 | 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), 49 | 'queue' => env('BEANSTALKD_QUEUE', 'default'), 50 | 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 51 | 'block_for' => 0, 52 | 'after_commit' => false, 53 | ], 54 | 55 | 'sqs' => [ 56 | 'driver' => 'sqs', 57 | 'key' => env('AWS_ACCESS_KEY_ID'), 58 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 59 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 60 | 'queue' => env('SQS_QUEUE', 'default'), 61 | 'suffix' => env('SQS_SUFFIX'), 62 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 63 | 'after_commit' => false, 64 | ], 65 | 66 | 'redis' => [ 67 | 'driver' => 'redis', 68 | 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 69 | 'queue' => env('REDIS_QUEUE', 'default'), 70 | 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), 71 | 'block_for' => null, 72 | 'after_commit' => false, 73 | ], 74 | 75 | ], 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Job Batching 80 | |-------------------------------------------------------------------------- 81 | | 82 | | The following options configure the database and table that store job 83 | | batching information. These options can be updated to any database 84 | | connection and table which has been defined by your application. 85 | | 86 | */ 87 | 88 | 'batching' => [ 89 | 'database' => env('DB_CONNECTION', 'sqlite'), 90 | 'table' => 'job_batches', 91 | ], 92 | 93 | /* 94 | |-------------------------------------------------------------------------- 95 | | Failed Queue Jobs 96 | |-------------------------------------------------------------------------- 97 | | 98 | | These options configure the behavior of failed queue job logging so you 99 | | can control how and where failed jobs are stored. Laravel ships with 100 | | support for storing failed jobs in a simple file or in a database. 101 | | 102 | | Supported drivers: "database-uuids", "dynamodb", "file", "null" 103 | | 104 | */ 105 | 106 | 'failed' => [ 107 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 108 | 'database' => env('DB_CONNECTION', 'sqlite'), 109 | 'table' => 'failed_jobs', 110 | ], 111 | 112 | ]; 113 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.jsx: -------------------------------------------------------------------------------- 1 | import InputError from '@/Components/InputError'; 2 | import InputLabel from '@/Components/InputLabel'; 3 | import PrimaryButton from '@/Components/PrimaryButton'; 4 | import TextInput from '@/Components/TextInput'; 5 | import { Link, useForm, usePage } from '@inertiajs/react'; 6 | import { Transition } from '@headlessui/react'; 7 | 8 | export default function UpdateProfileInformation({ mustVerifyEmail, status, className = '' }) { 9 | const user = usePage().props.auth.user; 10 | 11 | const { data, setData, patch, errors, processing, recentlySuccessful } = useForm({ 12 | name: user.name, 13 | email: user.email, 14 | }); 15 | 16 | const submit = (e) => { 17 | e.preventDefault(); 18 | 19 | patch(route('profile.update')); 20 | }; 21 | 22 | return ( 23 |
24 |
25 |

Profile Information

26 | 27 |

28 | Update your account's profile information and email address. 29 |

30 |
31 | 32 |
33 |
34 | 35 | 36 | setData('name', e.target.value)} 41 | required 42 | isFocused 43 | autoComplete="name" 44 | /> 45 | 46 | 47 |
48 | 49 |
50 | 51 | 52 | setData('email', e.target.value)} 58 | required 59 | autoComplete="username" 60 | /> 61 | 62 | 63 |
64 | 65 | {mustVerifyEmail && user.email_verified_at === null && ( 66 |
67 |

68 | Your email address is unverified. 69 | 75 | Click here to re-send the verification email. 76 | 77 |

78 | 79 | {status === 'verification-link-sent' && ( 80 |
81 | A new verification link has been sent to your email address. 82 |
83 | )} 84 |
85 | )} 86 | 87 |
88 | Save 89 | 90 | 97 |

Saved.

98 |
99 |
100 |
101 |
102 | ); 103 | } 104 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => env('AUTH_GUARD', 'web'), 18 | 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | which utilizes session storage plus the Eloquent user provider. 29 | | 30 | | All authentication guards have a user provider, which defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | system used by the application. Typically, Eloquent is utilized. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication guards have a user provider, which defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | system used by the application. Typically, Eloquent is utilized. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | providers to represent the model / table. These providers may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => env('AUTH_MODEL', App\Models\User::class), 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | These configuration options specify the behavior of Laravel's password 80 | | reset functionality, including the table utilized for token storage 81 | | and the user provider that is invoked to actually retrieve users. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'), 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | window expires and users are asked to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800), 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/Register.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import GuestLayout from '@/Layouts/GuestLayout'; 3 | import InputError from '@/Components/InputError'; 4 | import InputLabel from '@/Components/InputLabel'; 5 | import PrimaryButton from '@/Components/PrimaryButton'; 6 | import TextInput from '@/Components/TextInput'; 7 | import { Head, Link, useForm } from '@inertiajs/react'; 8 | 9 | export default function Register() { 10 | const { data, setData, post, processing, errors, reset } = useForm({ 11 | name: '', 12 | email: '', 13 | password: '', 14 | password_confirmation: '', 15 | }); 16 | 17 | useEffect(() => { 18 | return () => { 19 | reset('password', 'password_confirmation'); 20 | }; 21 | }, []); 22 | 23 | const submit = (e) => { 24 | e.preventDefault(); 25 | 26 | post(route('register')); 27 | }; 28 | 29 | return ( 30 | 31 | 32 | 33 |
34 |
35 | 36 | 37 | setData('name', e.target.value)} 45 | required 46 | /> 47 | 48 | 49 |
50 | 51 |
52 | 53 | 54 | setData('email', e.target.value)} 62 | required 63 | /> 64 | 65 | 66 |
67 | 68 |
69 | 70 | 71 | setData('password', e.target.value)} 79 | required 80 | /> 81 | 82 | 83 |
84 | 85 |
86 | 87 | 88 | setData('password_confirmation', e.target.value)} 96 | required 97 | /> 98 | 99 | 100 |
101 | 102 |
103 | 107 | Already registered? 108 | 109 | 110 | 111 | Register 112 | 113 |
114 |
115 |
116 | ); 117 | } 118 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Partials/UpdatePasswordForm.jsx: -------------------------------------------------------------------------------- 1 | import { useRef } from 'react'; 2 | import InputError from '@/Components/InputError'; 3 | import InputLabel from '@/Components/InputLabel'; 4 | import PrimaryButton from '@/Components/PrimaryButton'; 5 | import TextInput from '@/Components/TextInput'; 6 | import { useForm } from '@inertiajs/react'; 7 | import { Transition } from '@headlessui/react'; 8 | 9 | export default function UpdatePasswordForm({ className = '' }) { 10 | const passwordInput = useRef(); 11 | const currentPasswordInput = useRef(); 12 | 13 | const { data, setData, errors, put, reset, processing, recentlySuccessful } = useForm({ 14 | current_password: '', 15 | password: '', 16 | password_confirmation: '', 17 | }); 18 | 19 | const updatePassword = (e) => { 20 | e.preventDefault(); 21 | 22 | put(route('password.update'), { 23 | preserveScroll: true, 24 | onSuccess: () => reset(), 25 | onError: (errors) => { 26 | if (errors.password) { 27 | reset('password', 'password_confirmation'); 28 | passwordInput.current.focus(); 29 | } 30 | 31 | if (errors.current_password) { 32 | reset('current_password'); 33 | currentPasswordInput.current.focus(); 34 | } 35 | }, 36 | }); 37 | }; 38 | 39 | return ( 40 |
41 |
42 |

Update Password

43 | 44 |

45 | Ensure your account is using a long, random password to stay secure. 46 |

47 |
48 | 49 |
50 |
51 | 52 | 53 | setData('current_password', e.target.value)} 58 | type="password" 59 | className="mt-1 block w-full" 60 | autoComplete="current-password" 61 | /> 62 | 63 | 64 |
65 | 66 |
67 | 68 | 69 | setData('password', e.target.value)} 74 | type="password" 75 | className="mt-1 block w-full" 76 | autoComplete="new-password" 77 | /> 78 | 79 | 80 |
81 | 82 |
83 | 84 | 85 | setData('password_confirmation', e.target.value)} 89 | type="password" 90 | className="mt-1 block w-full" 91 | autoComplete="new-password" 92 | /> 93 | 94 | 95 |
96 | 97 |
98 | Save 99 | 100 | 107 |

Saved.

108 |
109 |
110 |
111 |
112 | ); 113 | } 114 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => (bool) env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | the application so that it's available within Artisan commands. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. The timezone 64 | | is set to "UTC" by default as it is suitable for most use cases. 65 | | 66 | */ 67 | 68 | 'timezone' => env('APP_TIMEZONE', 'UTC'), 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by Laravel's translation / localization methods. This option can be 77 | | set to any locale for which you plan to have translation strings. 78 | | 79 | */ 80 | 81 | 'locale' => env('APP_LOCALE', 'en'), 82 | 83 | 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), 84 | 85 | 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'), 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Encryption Key 90 | |-------------------------------------------------------------------------- 91 | | 92 | | This key is utilized by Laravel's encryption services and should be set 93 | | to a random, 32 character string to ensure that all encrypted values 94 | | are secure. You should do this prior to deploying the application. 95 | | 96 | */ 97 | 98 | 'cipher' => 'AES-256-CBC', 99 | 100 | 'key' => env('APP_KEY'), 101 | 102 | 'previous_keys' => [ 103 | ...array_filter( 104 | explode(',', env('APP_PREVIOUS_KEYS', '')) 105 | ), 106 | ], 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | Maintenance Mode Driver 111 | |-------------------------------------------------------------------------- 112 | | 113 | | These configuration options determine the driver used to determine and 114 | | manage Laravel's "maintenance mode" status. The "cache" driver will 115 | | allow maintenance mode to be controlled across multiple machines. 116 | | 117 | | Supported drivers: "file", "cache" 118 | | 119 | */ 120 | 121 | 'maintenance' => [ 122 | 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), 123 | 'store' => env('APP_MAINTENANCE_STORE', 'database'), 124 | ], 125 | 126 | ]; 127 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Deprecations Log Channel 26 | |-------------------------------------------------------------------------- 27 | | 28 | | This option controls the log channel that should be used to log warnings 29 | | regarding deprecated PHP and library features. This allows you to get 30 | | your application ready for upcoming major versions of dependencies. 31 | | 32 | */ 33 | 34 | 'deprecations' => [ 35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 36 | 'trace' => env('LOG_DEPRECATIONS_TRACE', false), 37 | ], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Log Channels 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Here you may configure the log channels for your application. Laravel 45 | | utilizes the Monolog PHP logging library, which includes a variety 46 | | of powerful log handlers and formatters that you're free to use. 47 | | 48 | | Available Drivers: "single", "daily", "slack", "syslog", 49 | | "errorlog", "monolog", "custom", "stack" 50 | | 51 | */ 52 | 53 | 'channels' => [ 54 | 55 | 'stack' => [ 56 | 'driver' => 'stack', 57 | 'channels' => explode(',', env('LOG_STACK', 'single')), 58 | 'ignore_exceptions' => false, 59 | ], 60 | 61 | 'single' => [ 62 | 'driver' => 'single', 63 | 'path' => storage_path('logs/laravel.log'), 64 | 'level' => env('LOG_LEVEL', 'debug'), 65 | 'replace_placeholders' => true, 66 | ], 67 | 68 | 'daily' => [ 69 | 'driver' => 'daily', 70 | 'path' => storage_path('logs/laravel.log'), 71 | 'level' => env('LOG_LEVEL', 'debug'), 72 | 'days' => env('LOG_DAILY_DAYS', 14), 73 | 'replace_placeholders' => true, 74 | ], 75 | 76 | 'slack' => [ 77 | 'driver' => 'slack', 78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 79 | 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), 80 | 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 81 | 'level' => env('LOG_LEVEL', 'critical'), 82 | 'replace_placeholders' => true, 83 | ], 84 | 85 | 'papertrail' => [ 86 | 'driver' => 'monolog', 87 | 'level' => env('LOG_LEVEL', 'debug'), 88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 89 | 'handler_with' => [ 90 | 'host' => env('PAPERTRAIL_URL'), 91 | 'port' => env('PAPERTRAIL_PORT'), 92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 93 | ], 94 | 'processors' => [PsrLogMessageProcessor::class], 95 | ], 96 | 97 | 'stderr' => [ 98 | 'driver' => 'monolog', 99 | 'level' => env('LOG_LEVEL', 'debug'), 100 | 'handler' => StreamHandler::class, 101 | 'formatter' => env('LOG_STDERR_FORMATTER'), 102 | 'with' => [ 103 | 'stream' => 'php://stderr', 104 | ], 105 | 'processors' => [PsrLogMessageProcessor::class], 106 | ], 107 | 108 | 'syslog' => [ 109 | 'driver' => 'syslog', 110 | 'level' => env('LOG_LEVEL', 'debug'), 111 | 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), 112 | 'replace_placeholders' => true, 113 | ], 114 | 115 | 'errorlog' => [ 116 | 'driver' => 'errorlog', 117 | 'level' => env('LOG_LEVEL', 'debug'), 118 | 'replace_placeholders' => true, 119 | ], 120 | 121 | 'null' => [ 122 | 'driver' => 'monolog', 123 | 'handler' => NullHandler::class, 124 | ], 125 | 126 | 'emergency' => [ 127 | 'path' => storage_path('logs/laravel.log'), 128 | ], 129 | 130 | ], 131 | 132 | ]; 133 | -------------------------------------------------------------------------------- /resources/js/Components/DeleteNotification.jsx: -------------------------------------------------------------------------------- 1 | import { useForm } from '@inertiajs/react' 2 | import { 3 | Button, 4 | Card, 5 | CardHeader, 6 | CardBody, 7 | CardFooter, 8 | Image 9 | } from '@nextui-org/react' 10 | import { useEffect, useState } from 'react' 11 | import ThumbsUp from './ThumbsUp' 12 | 13 | const DeleteNotification = ({ editor, entity, closeNotif }) => { 14 | const { delete: destroy } = useForm({ id: entity.article.id }) 15 | const [timeoutId, setTimeoutId] = useState(null) 16 | const duration = 6000 17 | 18 | useEffect(() => { 19 | // Clear any existing timeout 20 | if (timeoutId) { 21 | clearTimeout(timeoutId) 22 | } 23 | // Start a new timeout 24 | const newTimeoutId = setTimeout(() => { 25 | closeNotif(entity.article) 26 | }, duration) 27 | 28 | setTimeoutId(newTimeoutId) 29 | 30 | return () => { 31 | if (timeoutId) { 32 | clearTimeout(timeoutId) 33 | } 34 | } 35 | }, []) 36 | 37 | // Handle the delete approval request. 38 | const handleApproveDelete = () => { 39 | destroy(route('article.destroy'), { 40 | preserveScroll: true, 41 | onSuccess: () => closeNotif(entity.article) 42 | }) 43 | } 44 | 45 | // Stop the timer on mouse enter 46 | const handleMouseEnter = () => { 47 | if (timeoutId) { 48 | clearTimeout(timeoutId) 49 | } 50 | } 51 | 52 | // Restart the timer after mouse leave 53 | const handleMouseLeave = () => { 54 | const newTimeoutId = setTimeout(() => { 55 | closeNotif(entity) 56 | }, duration) 57 | 58 | setTimeoutId(newTimeoutId) 59 | } 60 | 61 | return ( 62 | 68 | 69 |
70 |
71 |

72 | Someone has requested to delete an article 73 |

74 |
75 |
76 | 101 |
102 | 103 |

104 | {editor.name} has 105 | requsted to delete the article{' '} 106 | {entity.article.title}. 107 | {entity.article.title} 115 | Do you want to allow this? 116 |

117 |
118 | 119 | 128 | 131 | 132 |
133 | ) 134 | } 135 | 136 | export default DeleteNotification 137 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'sqlite'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Database Connections 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Below are all of the database connections defined for your application. 27 | | An example configuration is provided for each database system which 28 | | is supported by Laravel. You're free to add / remove connections. 29 | | 30 | */ 31 | 32 | 'connections' => [ 33 | 34 | 'sqlite' => [ 35 | 'driver' => 'sqlite', 36 | 'url' => env('DB_URL'), 37 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 38 | 'prefix' => '', 39 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'url' => env('DB_URL'), 45 | 'host' => env('DB_HOST', '127.0.0.1'), 46 | 'port' => env('DB_PORT', '3306'), 47 | 'database' => env('DB_DATABASE', 'laravel'), 48 | 'username' => env('DB_USERNAME', 'root'), 49 | 'password' => env('DB_PASSWORD', ''), 50 | 'unix_socket' => env('DB_SOCKET', ''), 51 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 52 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 53 | 'prefix' => '', 54 | 'prefix_indexes' => true, 55 | 'strict' => true, 56 | 'engine' => null, 57 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 58 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 59 | ]) : [], 60 | ], 61 | 62 | 'mariadb' => [ 63 | 'driver' => 'mariadb', 64 | 'url' => env('DB_URL'), 65 | 'host' => env('DB_HOST', '127.0.0.1'), 66 | 'port' => env('DB_PORT', '3306'), 67 | 'database' => env('DB_DATABASE', 'laravel'), 68 | 'username' => env('DB_USERNAME', 'root'), 69 | 'password' => env('DB_PASSWORD', ''), 70 | 'unix_socket' => env('DB_SOCKET', ''), 71 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 72 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 73 | 'prefix' => '', 74 | 'prefix_indexes' => true, 75 | 'strict' => true, 76 | 'engine' => null, 77 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 78 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 79 | ]) : [], 80 | ], 81 | 82 | 'pgsql' => [ 83 | 'driver' => 'pgsql', 84 | 'url' => env('DB_URL'), 85 | 'host' => env('DB_HOST', '127.0.0.1'), 86 | 'port' => env('DB_PORT', '5432'), 87 | 'database' => env('DB_DATABASE', 'laravel'), 88 | 'username' => env('DB_USERNAME', 'root'), 89 | 'password' => env('DB_PASSWORD', ''), 90 | 'charset' => env('DB_CHARSET', 'utf8'), 91 | 'prefix' => '', 92 | 'prefix_indexes' => true, 93 | 'search_path' => 'public', 94 | 'sslmode' => 'prefer', 95 | ], 96 | 97 | 'sqlsrv' => [ 98 | 'driver' => 'sqlsrv', 99 | 'url' => env('DB_URL'), 100 | 'host' => env('DB_HOST', 'localhost'), 101 | 'port' => env('DB_PORT', '1433'), 102 | 'database' => env('DB_DATABASE', 'laravel'), 103 | 'username' => env('DB_USERNAME', 'root'), 104 | 'password' => env('DB_PASSWORD', ''), 105 | 'charset' => env('DB_CHARSET', 'utf8'), 106 | 'prefix' => '', 107 | 'prefix_indexes' => true, 108 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 109 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 110 | ], 111 | 112 | ], 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Migration Repository Table 117 | |-------------------------------------------------------------------------- 118 | | 119 | | This table keeps track of all the migrations that have already run for 120 | | your application. Using this information, we can determine which of 121 | | the migrations on disk haven't actually been run on the database. 122 | | 123 | */ 124 | 125 | 'migrations' => [ 126 | 'table' => 'migrations', 127 | 'update_date_on_publish' => true, 128 | ], 129 | 130 | /* 131 | |-------------------------------------------------------------------------- 132 | | Redis Databases 133 | |-------------------------------------------------------------------------- 134 | | 135 | | Redis is an open source, fast, and advanced key-value store that also 136 | | provides a richer body of commands than a typical key-value system 137 | | such as Memcached. You may define your connection settings here. 138 | | 139 | */ 140 | 141 | 'redis' => [ 142 | 143 | 'client' => env('REDIS_CLIENT', 'phpredis'), 144 | 145 | 'options' => [ 146 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 147 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 148 | ], 149 | 150 | 'default' => [ 151 | 'url' => env('REDIS_URL'), 152 | 'host' => env('REDIS_HOST', '127.0.0.1'), 153 | 'username' => env('REDIS_USERNAME'), 154 | 'password' => env('REDIS_PASSWORD'), 155 | 'port' => env('REDIS_PORT', '6379'), 156 | 'database' => env('REDIS_DB', '0'), 157 | ], 158 | 159 | 'cache' => [ 160 | 'url' => env('REDIS_URL'), 161 | 'host' => env('REDIS_HOST', '127.0.0.1'), 162 | 'username' => env('REDIS_USERNAME'), 163 | 'password' => env('REDIS_PASSWORD'), 164 | 'port' => env('REDIS_PORT', '6379'), 165 | 'database' => env('REDIS_CACHE_DB', '1'), 166 | ], 167 | 168 | ], 169 | 170 | ]; 171 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'database'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to expire immediately when the browser is closed then you may 31 | | indicate that via the expire_on_close configuration option. 32 | | 33 | */ 34 | 35 | 'lifetime' => env('SESSION_LIFETIME', 120), 36 | 37 | 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Session Encryption 42 | |-------------------------------------------------------------------------- 43 | | 44 | | This option allows you to easily specify that all of your session data 45 | | should be encrypted before it's stored. All encryption is performed 46 | | automatically by Laravel and you may use the session like normal. 47 | | 48 | */ 49 | 50 | 'encrypt' => env('SESSION_ENCRYPT', false), 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Session File Location 55 | |-------------------------------------------------------------------------- 56 | | 57 | | When utilizing the "file" session driver, the session files are placed 58 | | on disk. The default storage location is defined here; however, you 59 | | are free to provide another location where they should be stored. 60 | | 61 | */ 62 | 63 | 'files' => storage_path('framework/sessions'), 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Session Database Connection 68 | |-------------------------------------------------------------------------- 69 | | 70 | | When using the "database" or "redis" session drivers, you may specify a 71 | | connection that should be used to manage these sessions. This should 72 | | correspond to a connection in your database configuration options. 73 | | 74 | */ 75 | 76 | 'connection' => env('SESSION_CONNECTION'), 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Session Database Table 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When using the "database" session driver, you may specify the table to 84 | | be used to store sessions. Of course, a sensible default is defined 85 | | for you; however, you're welcome to change this to another table. 86 | | 87 | */ 88 | 89 | 'table' => env('SESSION_TABLE', 'sessions'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Session Cache Store 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using one of the framework's cache driven session backends, you may 97 | | define the cache store which should be used to store the session data 98 | | between requests. This must match one of your defined cache stores. 99 | | 100 | | Affects: "apc", "dynamodb", "memcached", "redis" 101 | | 102 | */ 103 | 104 | 'store' => env('SESSION_STORE'), 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Session Sweeping Lottery 109 | |-------------------------------------------------------------------------- 110 | | 111 | | Some session drivers must manually sweep their storage location to get 112 | | rid of old sessions from storage. Here are the chances that it will 113 | | happen on a given request. By default, the odds are 2 out of 100. 114 | | 115 | */ 116 | 117 | 'lottery' => [2, 100], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | Session Cookie Name 122 | |-------------------------------------------------------------------------- 123 | | 124 | | Here you may change the name of the session cookie that is created by 125 | | the framework. Typically, you should not need to change this value 126 | | since doing so does not grant a meaningful security improvement. 127 | | 128 | */ 129 | 130 | 'cookie' => env( 131 | 'SESSION_COOKIE', 132 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 133 | ), 134 | 135 | /* 136 | |-------------------------------------------------------------------------- 137 | | Session Cookie Path 138 | |-------------------------------------------------------------------------- 139 | | 140 | | The session cookie path determines the path for which the cookie will 141 | | be regarded as available. Typically, this will be the root path of 142 | | your application, but you're free to change this when necessary. 143 | | 144 | */ 145 | 146 | 'path' => env('SESSION_PATH', '/'), 147 | 148 | /* 149 | |-------------------------------------------------------------------------- 150 | | Session Cookie Domain 151 | |-------------------------------------------------------------------------- 152 | | 153 | | This value determines the domain and subdomains the session cookie is 154 | | available to. By default, the cookie will be available to the root 155 | | domain and all subdomains. Typically, this shouldn't be changed. 156 | | 157 | */ 158 | 159 | 'domain' => env('SESSION_DOMAIN'), 160 | 161 | /* 162 | |-------------------------------------------------------------------------- 163 | | HTTPS Only Cookies 164 | |-------------------------------------------------------------------------- 165 | | 166 | | By setting this option to true, session cookies will only be sent back 167 | | to the server if the browser has a HTTPS connection. This will keep 168 | | the cookie from being sent to you when it can't be done securely. 169 | | 170 | */ 171 | 172 | 'secure' => env('SESSION_SECURE_COOKIE'), 173 | 174 | /* 175 | |-------------------------------------------------------------------------- 176 | | HTTP Access Only 177 | |-------------------------------------------------------------------------- 178 | | 179 | | Setting this value to true will prevent JavaScript from accessing the 180 | | value of the cookie and the cookie will only be accessible through 181 | | the HTTP protocol. It's unlikely you should disable this option. 182 | | 183 | */ 184 | 185 | 'http_only' => env('SESSION_HTTP_ONLY', true), 186 | 187 | /* 188 | |-------------------------------------------------------------------------- 189 | | Same-Site Cookies 190 | |-------------------------------------------------------------------------- 191 | | 192 | | This option determines how your cookies behave when cross-site requests 193 | | take place, and can be used to mitigate CSRF attacks. By default, we 194 | | will set this value to "lax" to permit secure cross-site requests. 195 | | 196 | | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value 197 | | 198 | | Supported: "lax", "strict", "none", null 199 | | 200 | */ 201 | 202 | 'same_site' => env('SESSION_SAME_SITE', 'lax'), 203 | 204 | /* 205 | |-------------------------------------------------------------------------- 206 | | Partitioned Cookies 207 | |-------------------------------------------------------------------------- 208 | | 209 | | Setting this value to true will tie the cookie to the top-level site for 210 | | a cross-site context. Partitioned cookies are accepted by the browser 211 | | when flagged "secure" and the Same-Site attribute is set to "none". 212 | | 213 | */ 214 | 215 | 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), 216 | 217 | ]; 218 | -------------------------------------------------------------------------------- /resources/js/Pages/Dashboard.jsx: -------------------------------------------------------------------------------- 1 | import DeleteIcon from '@/Components/DeleteIcon' 2 | import Notification from '@/Components/Notification' 3 | import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' 4 | import { Head, router } from '@inertiajs/react' 5 | import { 6 | Card, 7 | CardHeader, 8 | CardBody, 9 | Image, 10 | Link, 11 | CardFooter, 12 | Button 13 | } from '@nextui-org/react' 14 | import { AnimatePresence, motion } from 'framer-motion' 15 | import { useState } from 'react' 16 | 17 | export default function Dashboard({ auth, articles }) { 18 | const [articleList, setArticleList] = useState(articles) 19 | const [notifications, setNotifications] = useState([]) 20 | 21 | const notifAnimation = { 22 | hidden: { opacity: 0, x: '100%' }, 23 | visible: { opacity: 1, x: 0 }, 24 | exit: { opacity: 0, x: '100%' } 25 | } 26 | 27 | const notifCardAnimation = { 28 | hidden: { opacity: 0 }, 29 | visible: { opacity: 1 }, 30 | exit: { opacity: 0 } 31 | } 32 | 33 | const handleDelete = article => { 34 | router.post( 35 | 'delete-article-request/', 36 | { 37 | id: article.id, 38 | user_id: auth.user.id 39 | }, 40 | { 41 | preserveScroll: true 42 | } 43 | ) 44 | 45 | setNotifications(prevNotifs => [...prevNotifs, article]) 46 | } 47 | 48 | // Handle the simple pagination navigation. 49 | const handlePageChange = url => { 50 | if (url) { 51 | router.get(url) 52 | } 53 | } 54 | 55 | const handleCloseNotif = article => { 56 | setNotifications(prevNotifs => 57 | prevNotifs.filter(notif => notif.id !== article.id) 58 | ) 59 | } 60 | 61 | const handleRemoveArticle = id => { 62 | setArticleList(prevArticleList => ({ 63 | ...prevArticleList, 64 | data: prevArticleList.data.filter(item => item.id !== id) 65 | })) 66 | } 67 | 68 | return ( 69 | 73 | {auth.user.role === 'chief-editor' 74 | ? 'The Glorified Chief 🤴🏼' 75 | : 'The Guy Who Do Most of the Work 😩'} 76 | 77 | } 78 | removeArticle={handleRemoveArticle} 79 | > 80 | 81 | 82 |
83 |
    84 | 85 | {notifications.map(article => ( 86 | 94 | 101 | 104 | handleCloseNotif(article) 105 | } 106 | /> 107 | 108 | 109 | ))} 110 | 111 |
112 |
113 | {auth.user.role === 'editor' && ( 114 | <> 115 |
116 | 117 | {articleList.data.map(article => ( 118 | 126 | 131 | 132 |

133 | Nature Blog 134 |

135 | 136 | {article.created_at} 137 | 138 |

139 | 144 | {article.title} 145 | 146 |

147 |
148 | 149 | Card background 161 | 162 | 163 | 170 | 182 | 183 |
184 |
185 | ))} 186 |
187 |
188 | 189 | {/* Pagination URL Links */} 190 |
191 | 203 | 215 |
216 | 217 | )} 218 | 219 | {auth.user.role === 'chief-editor' && ( 220 |
221 |

222 | I am the Chief Editor 223 |

224 |
225 | )} 226 |
227 |
228 |
229 | ) 230 | } 231 | -------------------------------------------------------------------------------- /resources/js/Layouts/AuthenticatedLayout.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react' 2 | import { Link } from '@inertiajs/react' 3 | import { AnimatePresence, motion } from 'framer-motion' 4 | import ApplicationLogo from '@/Components/ApplicationLogo' 5 | import Dropdown from '@/Components/Dropdown' 6 | import NavLink from '@/Components/NavLink' 7 | import ResponsiveNavLink from '@/Components/ResponsiveNavLink' 8 | import DeleteNotification from '@/Components/DeleteNotification' 9 | 10 | export default function Authenticated({ 11 | user, 12 | header, 13 | children, 14 | removeArticle 15 | }) { 16 | const [showingNavigationDropdown, setShowingNavigationDropdown] = 17 | useState(false) 18 | 19 | // Arry of notifications 20 | const [notifications, setNotifications] = useState([]) 21 | const [editor, setEditor] = useState(null) 22 | 23 | const variants = { 24 | hidden: { opacity: 0, x: '100%' }, 25 | visible: { opacity: 1, x: 0 }, 26 | exit: { opacity: 0, x: '100%' } 27 | } 28 | 29 | useEffect(() => { 30 | Echo.private(`management.${user.id}`) 31 | .listen('DeleteArticleRequestReceived', event => { 32 | // You can now do whatever you want here... 33 | console.log(event) 34 | setEditor(event.editor) 35 | setNotifications(prevArray => [...prevArray, event]) 36 | }) 37 | .listen('ArticleDeleted', event => { 38 | removeArticle(event.article.id) 39 | }) 40 | }, []) 41 | 42 | const handleCloseNotif = article => { 43 | setNotifications(prevNotifs => 44 | prevNotifs.filter(notif => notif.article.id !== article.id) 45 | ) 46 | } 47 | 48 | // This will only show the notifications for the intended receiver. 49 | const filteredNotifs = notifications.filter( 50 | notif => notif.chief.id === user.id 51 | ) 52 | 53 | return ( 54 |
55 |
    56 | 57 | {filteredNotifs.map(notif => ( 58 | 66 | 71 | 72 | ))} 73 | 74 |
75 | 76 | 227 | 228 | {header && ( 229 |
230 |
231 | {header} 232 |
233 |
234 | )} 235 | 236 |
{children}
237 |
238 | ) 239 | } 240 | --------------------------------------------------------------------------------