Chapter 2: The Fast-Track Foundation - Laravel 13, Routing, and Your First CRUD

Chapter 2
6 min read
2 reads
Prerequisites
To follow along with Laravel 13, ensure your local development environment has:
PHP 8.3 or higher (Laravel 13's absolute minimum requirement)
Composer (The PHP package manager)

A local database manager (MySQL, PostgreSQL, or SQLite)

Step 1: Laravel 13 Installation

Open your terminal, navigate to your development directory, and run the following command to create a brand-new project:

composer create-project laravel/laravel:^13.0 crash-course-app

Or

laravel new crash-course-app

Once Composer finishes downloading the framework core, change into the newly created directory:

cd crash-course-app

Now, boot up Laravel's built-in local development server:

php artisan serve

Step 2: Simple Landing Page (Routes, Controllers, Views)

Laravel follows the classic MVC (Model-View-Controller) pattern. Let’s create a custom landing page to see how data flows through this cycle.

1. The Route

Routes are the entry points of your application. Open routes/web.php and add a new route that points to a controller:

<?php

use App\Http\Controllers\PagesController;
use Illuminate\Support\Facades\Route;

// This maps a GET request on the homepage to a 'home' method inside PagesController
Route::get('/', [PagesController::class, 'home']);

2. The Controller

Next, we need to create that controller. Run this command in your terminal:

php artisan make:controller PagesController

This generates a file at app/Http/Controllers/PagesController.php. Open it and create the home method to pass some data down to a view layer:

<?php

namespace App\Http\Controllers;

class PagesController extends Controller
{
    public function home()
    {
        $businessStats = [
            'hoursSaved' => '1,200',
            'savedInSaaS' => '$14,500'
        ];

        return view('welcome', compact('businessStats'));
    }
}

3. The View

Laravel uses Blade, a incredibly powerful templating engine. Open resources/views/welcome.blade.php, delete everything inside it, and replace it with this clean HTML containing our dynamic PHP variables:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Operation Terminal</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-slate-900 text-white flex items-center justify-center min-h-screen">
    <div class="text-center p-8 bg-slate-800 rounded-xl shadow-2xl border border-slate-700">
        <h1 class="text-3xl font-black text-emerald-400 mb-2">Operation Active</h1>
        <p class="text-slate-400 mb-6">Internal Automation Framework</p>
        
        <div class="grid grid-cols-2 gap-4">
            <div class="bg-slate-900 p-4 rounded-lg">
                <span class="block text-2xl font-bold text-white">{{ $businessStats['hoursSaved'] }}</span>
                <span class="text-xs text-slate-500 uppercase">Hours Saved</span>
            </div>
            <div class="bg-slate-900 p-4 rounded-lg">
                <span class="block text-2xl font-bold text-emerald-400">{{ $businessStats['savedInSaaS'] }}</span>
                <span class="text-xs text-slate-500 uppercase">SaaS Costs Saved</span>
            </div>
        </div>
    </div>
</body>
</html>

Refresh your browser. You’ve just successfully routed data from a controller straight into a dynamic frontend.

Step 3: Database Project (Migrations, Eloquent, Seeders)

An internal business tool is nothing without a database. Let’s build a lightweight Blog Log system to learn how database tables are generated and populated.

By default, Laravel 13 uses SQLite, meaning you don't even need to configure a local database server! It automatically spins up a local database file out of the box.

1. The Migration & Model

We need a Post model and a database migration file to build the table structure. Let's generate both simultaneously:

php artisan make:model Post -m

The -m flag tells Laravel to create the database blueprint alongside the model code.

Open the newly created migration file inside the database/migrations/ directory. Modify the up method to define our column fields:

public function up(): void
{
    Schema::create('posts', function (Blueprint $table) {
        $table->id();
        $table->string('title');
        $table->text('content');
        $table->string('status')->default('draft'); // draft, published
        $table->timestamps();
    });
}

Now execute the migration to safely build this table inside your database:

php artisan migrate

2. The Seeder

To test our applications, we need dummy data. Let's create a database seeder:

php artisan make:seeder PostSeeder

Open database/seeders/PostSeeder.php and use Eloquent (Laravel's built-in Object-Relational Mapper) to insert mock entries:

<?php

namespace Database\Seeders;

use App\Models\Post;
use Illuminate\Database\Seeder;

class PostSeeder extends Seeder
{
    public function run(): void
    {
        Post::create([
            'title' => 'Automating Invoices with AI',
            'content' => 'This is a long-form breakdown on optimizing company cashflow rules.',
            'status' => 'published',
        ]);

        Post::create([
            'title' => 'Ditching Salesforce Forever',
            'content' => 'Why custom tools built with Filament beat heavy CRM platforms hands down.',
            'status' => 'draft',
        ]);
    }
}

Run your seeder to populate the database:

php artisan db:seed --class=PostSeeder

Step 4: Building a Rapid CRUD with an Authentication Starter Kit

When building internal enterprise apps, security is paramount. You can't have random internet traffic accessing financial pipelines or customer logs.

Instead of writing login forms, session cookies, and password hashing logic by hand, we are going to deploy Laravel Breeze—an official authentication starter kit that gives us security workflows out of the box.

1. Installing Breeze

Run the following commands to pull in Breeze and install its lightweight frontend scaffolding:

composer require laravel/breeze --dev
php artisan breeze:install blade

(Select the default options when prompted by the installer).

Run the migration command one more time to ensure any new authentication fields are added to your database:

php artisan migrate

2. The Form Validation & Secure CRUD Experience

Go back to your browser and look at your application homepage. You will notice a Login and Register link have automatically appeared in the top right corner! Go ahead and register a new test user account.

Once registered, you will be redirected to a secure /dashboard view that only authenticated accounts can access.

Let's quickly build out a simple form validation route inside routes/web.php to see how easily Laravel handles raw user input securely:

use Illuminate\Http\Request;
use App\Models\Post;

Route::post('/posts', function (Request $request) {
    // 1. Enforce strict validation requirements
    $validated = $request->validate([
        'title' => 'required|max:255|string',
        'content' => 'required|min:10',
    ]);

    // 2. Safely create the record if validation passes
    Post::create($validated);

    return back()->with('success', 'Post saved securely!');
})->middleware(['auth']); // This explicit middleware protects this route from unauthenticated traffic

The Foundation is Set

You now understand the core fundamentals of the Laravel framework ecosystem:

  • You can install and boot up the environment core.
  • You know how to route user traffic through secure controllers into layouts.
  • You know how to create structural database migrations and seed them with mock items.
  • You have implemented a full enterprise-ready authentication system.

You are no longer looking at web development like a standard developer writing custom CSS and JavaScript frameworks. You are now architecting data engines.

In Chapter 3, we are taking this foundation and injecting the true hero of this series: Filament. We will see how to drop Filament into this application and instantly generate beautiful data management panels with zero frontend layout code required

Want to support this author?

By unlocking the full story, you directly support local writers. You'll also be able to track your reads, and discover amazing content!

Chapter 2: The Fast-Track Foundation - Laravel 13, Routing, and Your First CRUD - Ship the Operation | Soma