-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement subject matter create, and showing list of subject matter f…
…or classroom
- Loading branch information
1 parent
a8927d1
commit d163860
Showing
8 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Models\Classroom; | ||
use App\Models\SubjectMatter; | ||
|
||
class SubjectMatterController extends Controller | ||
{ | ||
public function classroom() { | ||
return $this->belongsTo(Classroom::class); | ||
} | ||
|
||
public function indexSubjectMatter(Classroom $classroom) { | ||
$subjects = SubjectMatter::where('classroom_id', $classroom->id)->get(); | ||
|
||
return view('teacher.course.subjectmatter', [ | ||
'classroom' => $classroom, | ||
'subjects' => $subjects | ||
]); | ||
} | ||
|
||
public function showSubjectMatter(Classroom $classroom, SubjectMatter $subject) { | ||
return "a single subjectmatter: {$subject->title}"; | ||
} | ||
|
||
public function createSubjectMatter(Classroom $classroom) { | ||
return view('teacher.class.createsubjectmatter', [ | ||
'classroom' => $classroom | ||
]); | ||
} | ||
|
||
public function storeSubjectMatter(Classroom $classroom, Request $request) { | ||
$this->validate($request, [ | ||
'title' => 'required|max:255', | ||
'link' => 'url', | ||
'content' => 'required' | ||
]); | ||
|
||
$classroom->subjectMatters()->create([ | ||
'title' => $request->title, | ||
'link' => $request->link, | ||
'content' => $request->content | ||
]); | ||
|
||
return redirect()->route('subjectmatter', $classroom->id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters