this example for you to leaning more about laravel. This example I want to talking about CRUD.

CRUD meaning that creat, read, update and delete data on database.

if you just learning laravel and don’t know how to install laravel.

I have wrote some tutorials for you.

Step #1 create file controller and model


c:\>php artisan make:controller assignsubjectctrl
c:\>php artisan make:model assignsubject -m

Step#2 create table field in migrations directory on table assignsubject, student_class and  subject
migration file  create_assign_subjects _table.php

public function up()
{
Schema::create('assign_subjects', function (Blueprint $table) {
$table->id();
$table->integer('class_id');                      //add field class_id  as integer
$table->integer('subject_id');                 // add field subject_id as integer
$table->double('full_mark');                  // add fileld full_mark as double
$table->double('pass_mark');                // add filed pass_mark as double
$table->double('subjective_mark');       // add filed subjective_mark as double
$table->timestamps();
});
}

migration file  create_school_subjects _table.php


public function up()
{
Schema::create('school_subjects', function (Blueprint $table) {
$table->id();
$table->string('name')->unique(); //add filed name as string
$table->timestamps();
});
}

migration file  create_student_classes_table.php

public function up()
{
Schema::create('student_classes', function (Blueprint $table) {
$table->id();
$table->string('name')->unique(); //add filed name as string
$table->timestamps();
});
}

Step#4

Now you have to run this migration by following command:

c:\>PHP artisan migrate

Step#5 create view

Leave a Reply

Your email address will not be published. Required fields are marked *