This video will be available to
subscribers on Thu, Dec 18, 2025.
subscribers on Thu, Dec 18, 2025.
You must be a subscriber to view this video.
Dec 18, 2025
23m
Controller Basics
Classification
Software Engineering | Frameworks | Laravel
Keywords
laravel | php
About This Episode:
In this episode, we tie together Routes, Models, and Views by introducing the Controller — the final piece of Laravel’s MVC architecture.
You’ll learn how to:
✅ Create controllers using php artisan make:controller
✅ Organize request-handling logic into clean, reusable classes
✅ Connect routes to controller methods (actions)
✅ Implement GET and POST routes for taking a survey
✅ Apply route model binding and request/response patterns
We’ll also clean up a few loose ends before diving into survey submissions:
- Add default error pages
- Rename SurveyStatusType → SurveyStatus
- Guard routes against non-active surveys
- Add an index to hash in migrations
- Demonstrate booted() and enum casting in the Survey model
- Simplify the factory by removing hash logic
Copy these commands to follow along:
php artisan make:controller TakeSurveyController
Example routes:
- Route::get('/s/{survey:hash}', [TakeSurveyController::class, 'show'])->name('survey.show');
- Route::post('/s/{survey:hash}', [TakeSurveyController::class, 'store'])->name('survey.store');
📘 Resources
- Laravel Controllers Docs: https://laravel.com/docs/12.x/controllers
- Laravel Routing Docs: https://laravel.com/docs/12.x/routing
- Laravel Model Events Docs: https://laravel.com/docs/12.x/eloquent#events
- Laravel Error Pages Docs: https://laravel.com/docs/12.x/errors#http-exceptions
- Migration Modifications Docs: https://laravel.com/docs/12.x/migrations#modifying-columns
#Laravel #PHP #WebDevelopment #MVC #Controllers #Routing #Eloquent #TekCasts #LearnToCode
You’ll learn how to:
✅ Create controllers using php artisan make:controller
✅ Organize request-handling logic into clean, reusable classes
✅ Connect routes to controller methods (actions)
✅ Implement GET and POST routes for taking a survey
✅ Apply route model binding and request/response patterns
We’ll also clean up a few loose ends before diving into survey submissions:
- Add default error pages
- Rename SurveyStatusType → SurveyStatus
- Guard routes against non-active surveys
- Add an index to hash in migrations
- Demonstrate booted() and enum casting in the Survey model
- Simplify the factory by removing hash logic
Copy these commands to follow along:
php artisan make:controller TakeSurveyController
Example routes:
- Route::get('/s/{survey:hash}', [TakeSurveyController::class, 'show'])->name('survey.show');
- Route::post('/s/{survey:hash}', [TakeSurveyController::class, 'store'])->name('survey.store');
📘 Resources
- Laravel Controllers Docs: https://laravel.com/docs/12.x/controllers
- Laravel Routing Docs: https://laravel.com/docs/12.x/routing
- Laravel Model Events Docs: https://laravel.com/docs/12.x/eloquent#events
- Laravel Error Pages Docs: https://laravel.com/docs/12.x/errors#http-exceptions
- Migration Modifications Docs: https://laravel.com/docs/12.x/migrations#modifying-columns
#Laravel #PHP #WebDevelopment #MVC #Controllers #Routing #Eloquent #TekCasts #LearnToCode
Short Bio:
Bob Cravens is a seasoned technology leader, software architect, and educator with a passion for empowering others through practical, real-world knowledge. As the founder of TekFoundry, Bob has dedicated his career to designing and delivering innovative software solutions that combine cutting-edge technology with elegant simplicity.
At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.
Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.
When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.
At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.
Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.
When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.