├── public ├── favicon.ico ├── robots.txt ├── index.php └── .htaccess ├── database ├── .gitignore ├── seeders │ └── DatabaseSeeder.php ├── migrations │ ├── 2025_03_10_201659_create_posts_table.php │ ├── 2025_03_10_201935_create_likes_table.php │ ├── 2025_03_10_201904_create_comments_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 └── factories │ └── UserFactory.php ├── bootstrap ├── cache │ └── .gitignore ├── providers.php └── app.php ├── resources ├── js │ ├── app.js │ └── bootstrap.js ├── sass │ ├── _variables.scss │ └── app.scss ├── css │ └── app.css └── views │ ├── home.blade.php │ ├── auth │ ├── verify.blade.php │ ├── passwords │ │ ├── email.blade.php │ │ ├── confirm.blade.php │ │ └── reset.blade.php │ ├── login.blade.php │ └── register.blade.php │ ├── posts │ ├── edit.blade.php │ ├── create.blade.php │ ├── index.blade.php │ └── show.blade.php │ ├── profiles │ ├── index.blade.php │ └── edit.blade.php │ ├── layouts │ └── app.blade.php │ └── welcome.blade.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── private │ │ └── .gitignore │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── README.md ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php └── Feature │ └── ExampleTest.php ├── .gitattributes ├── .editorconfig ├── routes ├── console.php └── web.php ├── app ├── Http │ └── Controllers │ │ ├── Controller.php │ │ ├── HomeController.php │ │ ├── LikeController.php │ │ ├── Auth │ │ ├── ForgotPasswordController.php │ │ ├── ResetPasswordController.php │ │ ├── ConfirmPasswordController.php │ │ ├── LoginController.php │ │ ├── VerificationController.php │ │ └── RegisterController.php │ │ ├── CommentController.php │ │ ├── ProfileController.php │ │ └── PostController.php ├── Providers │ └── AppServiceProvider.php └── Models │ ├── Like.php │ ├── Comment.php │ ├── Post.php │ └── User.php ├── vite.config.js ├── .gitignore ├── artisan ├── package.json ├── config ├── services.php ├── filesystems.php ├── mail.php ├── cache.php ├── queue.php ├── auth.php ├── app.php ├── logging.php ├── database.php └── session.php ├── phpunit.xml ├── .env.example └── composer.json /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/private/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !private/ 3 | !public/ 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repo goes along with this course on the freeCodeCamp YouTube channel: https://www.youtube.com/watch?v=VK-2j5CNsvM 2 | -------------------------------------------------------------------------------- /bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 10 | })->purpose('Display an inspiring quote'); 11 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss'; 2 | 3 | @source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php'; 4 | @source '../../storage/framework/views/*.php'; 5 | @source "../**/*.blade.php"; 6 | @source "../**/*.js"; 7 | @source "../**/*.vue"; 8 | 9 | @theme { 10 | --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 11 | 'Segoe UI Symbol', 'Noto Color Emoji'; 12 | } 13 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 17 | 18 | exit($status); 19 | -------------------------------------------------------------------------------- /app/Models/Like.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 20 | } 21 | 22 | public function post() 23 | { 24 | return $this->belongsTo(Post::class); 25 | } 26 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "build": "vite build", 6 | "dev": "vite" 7 | }, 8 | "devDependencies": { 9 | "@popperjs/core": "^2.11.6", 10 | "@tailwindcss/vite": "^4.0.0", 11 | "axios": "^1.7.4", 12 | "bootstrap": "^5.2.3", 13 | "concurrently": "^9.0.1", 14 | "laravel-vite-plugin": "^1.2.0", 15 | "sass": "^1.56.1", 16 | "tailwindcss": "^4.0.0", 17 | "vite": "^6.0.11" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Models/Comment.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 21 | } 22 | 23 | public function post() 24 | { 25 | return $this->belongsTo(Post::class); 26 | } 27 | } -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | 18 | User::factory()->create([ 19 | 'name' => 'Test User', 20 | 'email' => 'test@example.com', 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 9 | web: __DIR__.'/../routes/web.php', 10 | commands: __DIR__.'/../routes/console.php', 11 | health: '/up', 12 | ) 13 | ->withMiddleware(function (Middleware $middleware) { 14 | // 15 | }) 16 | ->withExceptions(function (Exceptions $exceptions) { 17 | // 18 | })->create(); 19 | -------------------------------------------------------------------------------- /app/Http/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | } 18 | 19 | /** 20 | * Show the application dashboard. 21 | * 22 | * @return \Illuminate\Contracts\Support\Renderable 23 | */ 24 | public function index() 25 | { 26 | return view('home'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 21 | -------------------------------------------------------------------------------- /app/Http/Controllers/LikeController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 13 | } 14 | 15 | public function store(Post $post) 16 | { 17 | $post->likes()->create([ 18 | 'user_id' => auth()->id(), 19 | ]); 20 | 21 | return back(); 22 | } 23 | 24 | public function destroy(Post $post) 25 | { 26 | $post->likes()->where('user_id', auth()->id())->delete(); 27 | 28 | return back(); 29 | } 30 | } -------------------------------------------------------------------------------- /database/migrations/2025_03_10_201659_create_posts_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->timestamps(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | */ 23 | public function down(): void 24 | { 25 | Schema::dropIfExists('posts'); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /database/migrations/2025_03_10_201935_create_likes_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->timestamps(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | */ 23 | public function down(): void 24 | { 25 | Schema::dropIfExists('likes'); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /app/Models/Post.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 22 | } 23 | 24 | public function comments() 25 | { 26 | return $this->hasMany(Comment::class); 27 | } 28 | 29 | public function likes() 30 | { 31 | return $this->hasMany(Like::class); 32 | } 33 | } -------------------------------------------------------------------------------- /database/migrations/2025_03_10_201904_create_comments_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->timestamps(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | */ 23 | public function down(): void 24 | { 25 | Schema::dropIfExists('comments'); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /resources/views/home.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
{{ $user->bio }}
24 |{{ $post->likes->count() }} likes
44 | @if($post->user) 45 |{{ $post->user->username }} {{ $post->caption }}
46 | @else 47 |{{ $post->caption }}
48 | @endif 49 | 50 | View all {{ $post->comments->count() }} comments 51 | 52 |{{ $post->created_at->diffForHumans() }}
53 |{{ $post->user->username }} {{ $post->caption }}
44 | @else 45 |{{ $post->caption }}
46 | @endif 47 |{{ $post->likes->count() }} likes
68 |{{ $post->created_at->format('F d, Y') }}
69 | 70 |Laravel has an incredibly rich ecosystem.
We suggest starting with the following.
{{ $comment->comment }}
81 | 82 | @if(auth()->id() === $comment->user_id || auth()->id() === $post->user_id) 83 | 90 | @endif 91 |