Compare commits

...

3 Commits

33 changed files with 825 additions and 30 deletions

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class GroupController extends Controller
{
//
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreLessonRequest;
use App\Http\Requests\UpdateLessonRequest;
use App\Models\Lesson;
class LessonController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreLessonRequest $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(Lesson $lesson)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Lesson $lesson)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateLessonRequest $request, Lesson $lesson)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Lesson $lesson)
{
//
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class StudentController extends Controller
{
//
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SubGroupController extends Controller
{
//
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Http\Controllers;
class TeacherController extends Controller
{
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreLessonRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateLessonRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}

22
app/Models/Group.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Group extends Model
{
use HasFactory;
protected $attributes = [
'name'
];
public function student(): HasMany
{
return $this-hasMany(Student::class);
}
}

18
app/Models/Lesson.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Lesson extends Model
{
/** @use HasFactory<\Database\Factories\LessonFactory> */
use HasFactory;
protected $fillable = [
'topic'
];
}

25
app/Models/Student.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Student extends Model
{
Use HasFactory;
protected $fillable = [
'name',
'email',
'age',
'enrollment_date',
];
public function lessons()
{
return $this->hasMany(Lesson::class);
}
// TODO: apparently not needed? why? dont know yet... :-)
protected $table = 'lessons';
}

22
app/Models/SubGroup.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
class SubGroup extends Model
{
use HasFactory;
protected $attributes = [
];
public function student(): HasMany
{
return $this-hasMany(Student::class);
}
}

26
app/Models/Teacher.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Models\Group;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Teacher extends Model
{
use HasFactory;
protected $table = 'teacher';
/**
* @return HasMany
*/
public function group(): HasMany
{
return $this->hasMany(Group::class);
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\Group;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class GroupPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return false;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Group $group): bool
{
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return false;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Group $group): bool
{
return false;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Group $group): bool
{
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Group $group): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Group $group): bool
{
return false;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\Lesson;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class LessonPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return false;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Lesson $lesson): bool
{
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return false;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Lesson $lesson): bool
{
return false;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Lesson $lesson): bool
{
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Lesson $lesson): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Lesson $lesson): bool
{
return false;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\Student;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class StudentPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return false;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Student $student): bool
{
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return false;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Student $student): bool
{
return false;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Student $student): bool
{
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Student $student): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Student $student): bool
{
return false;
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace App\Policies;
use App\Models\SubGroup;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class SubGroupPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return false;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, SubGroup $subGroup): bool
{
return false;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return false;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, SubGroup $subGroup): bool
{
return false;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, SubGroup $subGroup): bool
{
return false;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, SubGroup $subGroup): bool
{
return false;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, SubGroup $subGroup): bool
{
return false;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Group>
*/
class GroupFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Lesson>
*/
class LessonFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Student>
*/
class StudentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\SubGroup>
*/
class SubGroupFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Teacher>
*/
class TeacherFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@ -11,15 +11,10 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::create('class', function(Blueprint $table) Schema::create('groups', function (Blueprint $table) {
{ $table->id();
$table->id('name');
$table->string('name'); $table->string('name');
$table->foreignId('teacher_id'); $table->timestamps();
$table->time('start_time');
$table->time('end_time');
// amount of students can be calculated
}); });
} }
@ -28,6 +23,6 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::drop('class'); Schema::dropIfExists('groups');
} }
}; };

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('sub_groups', function (Blueprint $table) {
$table->id();
$table->foreignId('group_id')->constrained()->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('sub_groups');
}
};

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('lessons', function (Blueprint $table) {
$table->id();
$table->string('topic');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('lessons');
}
};

View File

@ -11,7 +11,10 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
// Schema::create('groups', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
} }
/** /**
@ -19,6 +22,6 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
// Schema::dropIfExists('groups');
} }
}; };

View File

@ -11,16 +11,14 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::create('student', function (Blueprint $table) { Schema::create('students', function (Blueprint $table) {
$table->id();
$table->id; $table->timestamps();
$table->string('name'); $table->string('name');
$table->string('last_name'); $table->string('last_name');
$table->foreignId(['group_id']); $table->foreignId(['group_id']);
$table->foreignId(['class_id']); $table->foreignId(['class_id']);
$table->integer('points'); $table->integer('points');
$table->timestamp();
}); });
} }
@ -29,7 +27,6 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::dropIfExists('students');
Schema::drop('student');
} }
}; };

View File

@ -9,16 +9,13 @@ return new class extends Migration
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up(): void public function up(): void
{ {
Schema::create('teacher', function (Blueprint $table) { Schema::create('teachers', function (Blueprint $table) {
$table->id();
$table->id; $table->timestamps();
$table->string('name'); $table->string('name');
$table->string('last_name'); $table->string('last_name');
$table->timestamp();
}); });
} }
@ -27,6 +24,6 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::drop('teacher'); Schema::dropIfExists('teachers');
} }
}; };

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class GroupSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class LessonSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class StudentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class SubGroupSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TeacherSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -1,11 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Hello</title> <title>Teacher's Journal</title>
</head> </head>
<body> <body>
<header>
Hello world <ul>
</body> <li>home</li>
<li>about</li>
<li>login</li>
<li>register</li>
</ul>
</header
<div>
Document the courses you've teached.
</div>
</body>
</html> </html>