Skip to content

Commit

Permalink
Implementing Subject Matter, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
danivideda committed Dec 2, 2020
1 parent 1689bb1 commit a8927d1
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 16 deletions.
18 changes: 17 additions & 1 deletion app/Http/Controllers/ClassroomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ClassroomController extends Controller
{
public function index() {
public function showCreateClassroom() {
return view('teacher.home.createclass');
}

Expand All @@ -24,4 +24,20 @@ public function store(Request $request) {

return redirect()->route('teacher.dashboard');
}

public function indexSubjectMatter(Classroom $classroom) {
return view('teacher.course.subjectmatter', [
'classroom' => $classroom
]);
}

public function showSubjectMatter(Classroom $classroom) {
return view('teacher.course.subjectmatter', [
'classroom' => $classroom
]);
}

public function createSubjectMatter(Classroom $classroom) {
return view('teacher.class.createsubjectmatter');
}
}
16 changes: 16 additions & 0 deletions app/Models/Classroom.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@ class Classroom extends Model
'assignments' => 'array',
'students_joined' => 'array'
];

public function students() {
return $this->hasMany(Student::class);
}

public function subjectMatters() {
return $this->hasMany(SubjectMatter::class);
}

public function teacher() {
return $this->belongsTo(Teacher::class);
}

public function path() {
return "/teacher/classroom/{$this->id}/subject-matter";
}
}
17 changes: 17 additions & 0 deletions app/Models/SubjectMatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SubjectMatter extends Model
{
use HasFactory;

protected $fillable = [
'title',
'url',
'content'
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSubjectMattersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subject_matters', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('url')->nullable();
$table->text('content');
$table->foreignId('classroom_id')->constrained()->onDelete('cascade');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subject_matters');
}
}
10 changes: 5 additions & 5 deletions resources/views/teacher/course/subjectmatter.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<div class="container">
<div class="flex flex-wrap flex-col md:flex-row items-center bg-white mt-2 mb-10 w-9/12 mx-auto rounded-lg">
<div class="flex flex-col xl:w-2/5 overflow-y-hidden lg:items-start pl-4">
<h1 class="text-xl text-black text-left mb-4">Pemrograman</h1>
<h1 class="text-sm text-blacktext-left">Melati</h1>
<p class="text-sm text-left">SMAN 8 Jogja</p>
<h1 class="text-xl text-black text-left mb-4">{{ $classroom->class_name }}</h1>
<h1 class="text-sm text-blacktext-left">{{ auth('teacher')->user()->name }}</h1>
<p class="text-sm text-left">{{ auth('teacher')->user()->school_name }}</p>
</div>
<div class="xl:w-3/5 overflow-y-hidden rounded-lg">
<img class="w-full rounded-lg" src="{{asset('img/logo.PNG')}}">
Expand All @@ -35,7 +35,7 @@
<div class="bg-white w-4/12 mx-auto my-6 rounded flex bg-gray-200 hover:bg-gray-300">
<h1 class="text-black text-base w-10/12 px-4 py-4">Create New Subject Matter</h1>
<h1 class="text-black text-base italic font-extrabold w-2/12 px-4 py-4">+</h1>
</div>
</div>
</a>

<div class="my-4 text-black text-xl font-bold mx-auto w-9/12">
Expand All @@ -45,7 +45,7 @@
<a href="#">
<div class="bg-white w-9/12 mx-auto px-4 py-4 my-6 rounded border-2 hover:border-gray-600">
<h1 class="text-black text-base italic">Test</h1>
</div>
</div>
</a>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/teacher/home/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<div class="container w-full">
@if ($classrooms->count())
@foreach ($classrooms as $classroom)
<a href="#">
<a href="{{ $classroom->path() }}">
<div class="flex flex-wrap flex-col md:flex-row items-center bg-white my-8 w-9/12 mx-auto rounded-lg border-2 hover:border-gray-600">
<div class="flex flex-col xl:w-2/5 overflow-y-hidden lg:items-start pl-4">
<h1 class="text-xl text-black text-left mb-4">{{ $classroom->class_name }}</h1>
<h1 class="text-sm text-blacktext-left">{{ auth('teacher')->user()->name }}</h1>
<p class="text-sm text-left">{{ auth('teacher')->user()->school_name }}</p>
<h1 class="text-sm text-blacktext-left">{{ $classroom->teacher->name }}</h1>
<p class="text-sm text-left">{{ $classroom->teacher->school_name }}</p>
<p class="text-sm text-left">Code: {{ $classroom->code }}</p>
</div>
<div class="xl:w-3/5 overflow-y-hidden rounded-lg">
Expand Down
12 changes: 5 additions & 7 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@
Route::middleware('auth.teacher')->group(function () {
Route::get('/teacher/dashboard', [TeacherController::class, 'index'])->name('teacher.dashboard');

Route::get('/teacher/classroom/create', [ClassroomController::class, 'index'])->name('classroom.create');
Route::get('/teacher/classroom/create', [ClassroomController::class, 'showCreateClassroom'])->name('classroom.create');
Route::post('/teacher/classroom/create', [ClassroomController::class, 'store']);

Route::get('/teacher/subject-matter', function () {
return view('teacher.course.subjectmatter');
});
Route::get('/teacher/subject-matter/create', function () {
return view('teacher.class.createsubjectmatter');
});
Route::get('/teacher/classroom/{classroom}/subject-matter', [ClassroomController::class, 'indexSubjectMatter'])->name('classroom.subjectmatter');
Route::get('/teacher/classroom/{classroom}/subject-matter/create', [ClassroomController::class, 'createSubjectMatter']);
Route::get('/teacher/classroom/{classroom}/subject-matter/{subject}', [ClassroomController::class, 'showSubjectMatter']);
// Route::post('/teacher/classroom/{classroom}/subject-matter/create', [ClassroomController::class, 'storeSubjectMatter']);

Route::get('/teacher/assignment', function () {
return view('teacher.course.assignment');
Expand Down

0 comments on commit a8927d1

Please sign in to comment.