Build a Simple Student Info App with Laravel 12 and Laragon Server (Step-by-Step)

Laravel Student Project — Full Course (Step-by-Step)

Table of Contents

  • Overview
  • Prerequisites
  • Step 1 — Create Project
  • Step 2 — Create Database
  • Step 3 — Configure .env
  • Step 4 — Model & Migration
  • Step 5 — Seeder
  • Step 6 — Controller & Routes
  • Step 7 — Blade Views
  • Step 8 — Run & Test

Overview

This course walks students through building a simple Student Info app in Laravel. It’s deliberately manual so you can learn every step: CLI commands, migrations, model, seeder, controller, routes, and Blade views.

 

Prerequisites

  • Windows + Laragon (or equivalent local environment)
  • PHP ≥ 8.1
  • Composer installed
  • Basic command line and text editor knowledge

 

Step 1 — Create Laravel Project

🐘
composer
Copy to clipboard
cd C:\laragon\www
composer create-project laravel/laravel student-info
cd student-info

Step 2 — Create the Database

🐘
composer
Copy to clipboard
CREATE DATABASE student_info CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Step 3 — Configure .env

🐘
.ENV
Copy to clipboard
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=student_info
DB_USERNAME=root
DB_PASSWORD=

Step 4 — Create Model & Migration

🐘
Copy to clipboard
php artisan make:model Student -m

Migration example:

🐘
Copy to clipboard
public function up()
{
Schema::create(‘students’, function (Blueprint $table) {
$table->id();
$table->string(‘first_name’, 50);
$table->string(‘last_name’, 50);
$table->string(’email’)->unique();
$table->date(‘dob’)->nullable();
$table->enum(‘gender’, [‘Male’,’Female’,’Other’])->default(‘Male’);
$table->string(‘course’)->nullable();
$table->integer(‘score’)->nullable();
$table->timestamps();
});
}

Step 5 — Seeder (Sample Data)

🐘
Copy to clipboard
php artisan make:seeder StudentSeeder

Seeder content:

🐘
Copy to clipboard
DB::table(‘students’)->insert([
[
‘first_name’ => ‘Alice’,
‘last_name’ => ‘Karanja’,
’email’ => ‘alice@example.com’,
‘dob’ => ‘2001-04-15’,
‘gender’ => ‘Female’,
‘course’ => ‘Computer Science’,
‘score’ => 88,
‘created_at’ => now(),
‘updated_at’ => now(),
],
[
‘first_name’ => ‘Brian’,
‘last_name’ => ‘Otieno’,
’email’ => ‘brian@example.com’,
‘dob’ => ‘2000-09-02’,
‘gender’ => ‘Male’,
‘course’ => ‘Information Systems’,
‘score’ => 75,
‘created_at’ => now(),
‘updated_at’ => now(),
],
]);

DatabaseSeeder.php:

public function run()
{
$this->call([
StudentSeeder::class,
]);
}

Step 6 — Controller & Routes

🐘
Copy to clipboard
php artisan make:controller StudentController

Controller content:

 
🐘
Copy to clipboard
public function index(Request $request)
{
$q = $request->query(‘q’);

$students = Student::when($q, function($query, $q) {
$query->where(‘first_name’,’like’,”%{$q}%”)
->orWhere(‘last_name’,’like’,”%{$q}%”)
->orWhere(’email’,’like’,”%{$q}%”);
})->orderBy(‘last_name’)->get();

return view(‘students.index’, compact(‘students’));
}

public function show($id)
{
$student = Student::findOrFail($id);
return view(‘students.show’, compact(‘student’));
}

Routes (routes/web.php):

use App\Http\Controllers\StudentController;

Route::get(‘/’, function () {
return redirect()->route(‘students.index’);
});

Route::get(‘/students’, [StudentController::class, ‘index’])->name(‘students.index’);
Route::get(‘/students/{id}’, [StudentController::class, ‘show’])->name(‘students.show’);

Step 7 — Blade Views

🌐
1. Layout — resources/views/layouts/app.blade.php
Copy to clipboard
<header>
    <h1>Learn with Calvince Harst – Harst Logics IT</h1>
    We make IT Happen | harstlogics.com
</header>

@yield('content')

<footer>
    © {{ date('Y') }} Harst Logics IT
</footer>
🌐
2. Index — resources/views/students/index.blade.php
Copy to clipboard
@extends('layouts.app')
@section('title','Students List')
@section('content')

<h2>Students</h2>
@if($students->isEmpty())
    No students found.
@else
    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Email</th>
                <th>Course</th>
                <th>Score</th>
            </tr>
        </thead>
        <tbody>
            @foreach($students as $student)
            <tr>
                <td>
                    <a href="{{ route('students.show',$student->id) }}">
                        {{ $student->first_name }} {{ $student->last_name }}
                    </a>
                </td>
                <td>{{ $student->email }}</td>
                <td>{{ $student->course ?? '--' }}</td>
                <td>{{ $student->score ?? '--' }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>
@endif
@endsection
🌐
3. Show — resources/views/students/show.blade.php
Copy to clipboard
@extends('layouts.app')
@section('title', $student->first_name . ' ' . $student->last_name)
@section('content')

<a href="{{ route('students.index') }}">← Back to list</a>

<h2>{{ $student->first_name }} {{ $student->last_name }}</h2>
Email: {{ $student->email }}
Date of Birth: {{ $student->dob ? \Carbon\Carbon::parse($student->dob)->format('F j, Y') : '--' }}
Gender: {{ $student->gender }}
Course: {{ $student->course ?? '--' }}
Score: {{ $student->score ?? '--' }}
Joined: {{ $student->created_at->diffForHumans() }}

@endsection

Step 8 — Run & Test

🐘
Copy to clipboard
php artisan migrate
php artisan db:seed
php artisan serve

Leave a Reply