php artisan make:model Admin --all




Download 2,35 Mb.
bet10/15
Sana18.05.2024
Hajmi2,35 Mb.
#242014
1   ...   7   8   9   10   11   12   13   14   15
Bog'liq
Dars jadvalini yaratish online platformasi

php artisan make:model Admin --all
Endi migrationga kirib unig strukturasın ishlab chiqamiz.
2023_01_18_121821_create_subjects_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubjectsTable extends Migration
{
public function up()
{
Schema::create('subjects', function (Blueprint $table) {
$table->id();
$table->text('name');
$table->text('teacher');
$table->timestamps();}); }
public function down()
{
Schema::dropIfExists('subjects');
}}
Bizga faqat 2 column kerak bo’ladı ismi (name) va teacher (ustoz) kerak bo’ladi. Bu columnlarni yaratib olamiz. Va ularning tipin yozishimiz shart hisoblanadi. Bular ismi (name) – string (yani qator) va teacher (domla) – text qilib olamiz.
2023_01_18_121839_create_students_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateStudentsTable extends Migration
{
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->id();
$table->text('fullname');
$table->text('login');
$table->text('password');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('students');
}
}
Bizga faqat 3 column kerak bo’ladı dastur ism,familiyasi(fullname), logini(login), paroli (password) kerak bo’ladi. Bu columnlarni yaratib olamiz. Va ularning tipin yozishimiz shart hisoblanadi. Bular ism, familiayasi(fullname) – string (yani qator), logini (login) – text va paroli (password) – text qilib olamiz.
2023_01_18_121908_create_results_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateResultsTable extends Migration
{
public function up()
{
Schema::create('results', function (Blueprint $table) {
$table->id();
$table->text('student_fullname');
$table->text('subject_name');
$table->boolean('status');
$table->integer('border_control');
$table->integer('final_control');
$table->integer('result');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('results');
}
}
Bizga faqat 6ta column kerak bo’ladı. Student ism, familiyasi(fullname), fan nomi(subject_name), oraliq nazorat(border_control), yakuniy nazorat(final_control), status, natija(result) kerak bo’ladi. Bu columnlarni yaratib olamiz. Va ularning tipin yozishimiz shart hisoblanadi. Bular border_control – integer, final_control – integer, subject_name – text, fullname - text qilib olamiz.
2023_01_18_123022_create_admins_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAdminsTable extends Migration
{
public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->id();
$table->text('login');
$table->text('password');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('admins');
}
}
Bizga 2ta column kerak. Login va parol kerak bo’ladi. Hammasini yozgannan keyin terminalga pastdagi kodniz yozamiz. php artisan migrate buyrug’inan foydalanamiz. Bu malumotlar bazasida (SQL) shunga smos tablica va columnlarni yaratib beradi. Agarda biz yana migrationnan foydalanadigan bo’lsak php artisan migrate:fresh buyrug’inan foydalanamiz. U orqali yana migrate qilish imkoniyatiga ega bo’lamiz. Biz yana php artisan migrate:refresh (refresh deganing o’zi yana deganni bildiradi) berganimizda bazadagi malumotlar o’chib ketadi.
Keyin web.php ichiga o’zimizga kerak yani internetta izlagan paytda chiqadigan narsalarimizni routes/web.php ichiga pastdagi ko’rinishda yozib chiqamiz:
use App\Http\Controllers\AdminController;
use App\Http\Controllers\ResultController;
use App\Http\Controllers\StudentController;
use App\Http\Controllers\SubjectController;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('registraciya');});
Route::get('/admin', [AdminController::class, 'index']);
Route::post('/login', [AdminController::class, 'login']);
Route::post('/registraciya', [StudentController::class, 'result']);
Route::get('/admins', [AdminController::class, 'create']);
Route::post('/create_result', [ResultController::class, 'create_result']);
Route::post('/edit_result', [ResultController::class, 'edit_result']);
Route::resource('student', StudentController::class);
Route::resource('subject', SubjectController::class);
Route::resource('result', ResultController::class);
Biz bu yerda takror-takrot urldan foydalanmaslik uchun “'student'”, “'subject'” , “'result'” degan resurslarni yaratib olamiz.

Download 2,35 Mb.
1   ...   7   8   9   10   11   12   13   14   15




Download 2,35 Mb.

Bosh sahifa
Aloqalar

    Bosh sahifa



php artisan make:model Admin --all

Download 2,35 Mb.