From f1b91b51aa9ba08e25f3b83f81fd857307519a47 Mon Sep 17 00:00:00 2001 From: Ibrahim Khail Shakil Date: Mon, 27 Nov 2023 13:44:07 +0600 Subject: [PATCH] nov,27,2023 - 1:43pm --- .../Backend/Courses/CourseController.php | 10 +- .../Backend/Courses/MaterialController.php | 113 ++++++++++++++++ app/Http/Controllers/MaterialController.php | 66 ---------- ...2023_11_26_034558_create_courses_table.php | 3 + ...23_11_26_153620_create_materials_table.php | 4 +- .../views/backend/course/create.blade.php | 47 +++++-- resources/views/backend/course/edit.blade.php | 50 +++++-- .../backend/course/material/create.blade.php | 117 +++++++++++++++++ .../backend/course/material/edit.blade.php | 124 ++++++++++++++++++ .../backend/course/material/index.blade.php | 113 ++++++++++++++++ 10 files changed, 553 insertions(+), 94 deletions(-) create mode 100644 app/Http/Controllers/Backend/Courses/MaterialController.php delete mode 100644 app/Http/Controllers/MaterialController.php create mode 100644 resources/views/backend/course/material/create.blade.php create mode 100644 resources/views/backend/course/material/edit.blade.php create mode 100644 resources/views/backend/course/material/index.blade.php diff --git a/app/Http/Controllers/Backend/Courses/CourseController.php b/app/Http/Controllers/Backend/Courses/CourseController.php index 2fcf67c..472da71 100644 --- a/app/Http/Controllers/Backend/Courses/CourseController.php +++ b/app/Http/Controllers/Backend/Courses/CourseController.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use App\Models\Course; use Illuminate\Http\Request; -use App\Models\CourseCategory; +use App\Models\CourseCategory; use App\Models\Instructor; use Exception; use File; @@ -47,7 +47,10 @@ public function store(Request $request) $course->type = $request->courseType; $course->price = $request->coursePrice; $course->subscription_price = $request->subscriptionPrice; + $course->start_from = $request->start_from; + $course->duration = $request->duration; $course->difficulty = $request->courseDifficulty; + $course->course_code = $request->course_code; $course->prerequisites_en = $request->prerequisites_en; $course->prerequisites_bn = $request->prerequisites_bn; $course->status = $request->status; @@ -87,7 +90,7 @@ public function edit($id) return view('backend.course.edit', compact('courseCategory', 'instructor', 'course')); } - /** + /** * Update the specified resource in storage. */ public function update(Request $request, $id) @@ -103,7 +106,10 @@ public function update(Request $request, $id) $course->type = $request->courseType; $course->price = $request->coursePrice; $course->subscription_price = $request->subscriptionPrice; + $course->start_from = $request->start_from; + $course->duration = $request->duration; $course->difficulty = $request->courseDifficulty; + $course->course_code = $request->course_code; $course->prerequisites_en = $request->prerequisites_en; $course->prerequisites_bn = $request->prerequisites_bn; $course->status = $request->status; diff --git a/app/Http/Controllers/Backend/Courses/MaterialController.php b/app/Http/Controllers/Backend/Courses/MaterialController.php new file mode 100644 index 0000000..bbad0ea --- /dev/null +++ b/app/Http/Controllers/Backend/Courses/MaterialController.php @@ -0,0 +1,113 @@ +title = $request->materialTitle; + $material->course_id = $request->courseId; + $material->type = $request->materialType; + $material->content_url = $request->contentURL; + + if ($material->save()) { + $this->notice::success('Data Saved'); + return redirect()->route('material.index'); + } else { + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } + } catch (Exception $e) { + dd($e); + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } + } + + /** + * Display the specified resource. + */ + public function show(Material $material) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + $course = Course::get(); + $material = Material::findOrFail(encryptor('decrypt', $id)); + return view('backend.course.material.edit', compact('course', 'material')); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + try { + $material = Material::findOrFail(encryptor('decrypt', $id)); + $material->title = $request->materialTitle; + $material->course_id = $request->courseId; + $material->type = $request->materialType; + $material->content_url = $request->contentURL; + + if ($material->save()) { + $this->notice::success('Data Saved'); + return redirect()->route('material.index'); + } else { + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } + } catch (Exception $e) { + dd($e); + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + $data = Material::findOrFail(encryptor('decrypt', $id)); + if ($data->delete()) { + $this->notice::error('Data Deleted!'); + return redirect()->back(); + } + } +} diff --git a/app/Http/Controllers/MaterialController.php b/app/Http/Controllers/MaterialController.php deleted file mode 100644 index ff48688..0000000 --- a/app/Http/Controllers/MaterialController.php +++ /dev/null @@ -1,66 +0,0 @@ -enum('type', ['free', 'paid', 'subscription'])->default('paid'); $table->decimal('price', 10, 2)->default(0.00)->nullable(); $table->decimal('subscription_price', 10, 2)->nullable(); + $table->timestamp('start_from')->nullable(); + $table->integer('duration')->nullable(); $table->text('prerequisites_en')->nullable(); $table->text('prerequisites_bn')->nullable(); $table->enum('difficulty', ['beginner', 'intermediate', 'advanced'])->nullable(); + $table->string('course_code')->nullable(); $table->string('image')->nullable(); $table->boolean('status')->default(1)->comment('1 active, 0 inactive'); $table->string('language')->default('en'); diff --git a/database/migrations/2023_11_26_153620_create_materials_table.php b/database/migrations/2023_11_26_153620_create_materials_table.php index 10dfc8a..85e5074 100644 --- a/database/migrations/2023_11_26_153620_create_materials_table.php +++ b/database/migrations/2023_11_26_153620_create_materials_table.php @@ -22,9 +22,9 @@ public function up(): void $table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade'); }); - } + } - /** + /** * Reverse the migrations. */ public function down(): void diff --git a/resources/views/backend/course/create.blade.php b/resources/views/backend/course/create.blade.php index 930e212..c5c5ef8 100644 --- a/resources/views/backend/course/create.blade.php +++ b/resources/views/backend/course/create.blade.php @@ -118,6 +118,18 @@ +
+
+ + +
+
@@ -140,17 +152,23 @@
- - + +
+ @if($errors->has('start_from')) + {{ $errors->first('start_from') }} + @endif +
+
+
+ + +
+ @if($errors->has('duration')) + {{ $errors->first('duration') }} + @endif
@@ -181,6 +199,15 @@
+
+
+ + +
+ @if($errors->has('course_code')) + {{ $errors->first('course_code') }} + @endif +
diff --git a/resources/views/backend/course/edit.blade.php b/resources/views/backend/course/edit.blade.php index 67cc46b..88a231e 100644 --- a/resources/views/backend/course/edit.blade.php +++ b/resources/views/backend/course/edit.blade.php @@ -131,6 +131,25 @@ {{ $errors->first('courseType') }} @endif
+
+
+ + +
+ @if($errors->has('courseDifficulty')) + {{ $errors->first('courseDifficulty') }} + @endif +
@@ -154,21 +173,24 @@
- - + +
- @if($errors->has('courseDifficulty')) - {{ $errors->first('courseDifficulty') }} + @if($errors->has('start_from')) + {{ $errors->first('start_from', + $course->start_from) }} + @endif +
+
+
+ + +
+ @if($errors->has('duration')) + {{ $errors->first('duration', + $course->duration) }} @endif
diff --git a/resources/views/backend/course/material/create.blade.php b/resources/views/backend/course/material/create.blade.php new file mode 100644 index 0000000..05e0c59 --- /dev/null +++ b/resources/views/backend/course/material/create.blade.php @@ -0,0 +1,117 @@ +@extends('backend.layouts.app') +@section('title', 'Add Course Material') + +@push('styles') + + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Add Course Material

+
+
+ +
+ +
+
+
+
+
Basic Info
+
+
+
+ @csrf +
+
+
+ + +
+ @if($errors->has('materialTitle')) + {{ $errors->first('materialTitle') }} + @endif +
+
+
+ + +
+ @if($errors->has('courseId')) + {{ $errors->first('courseId') }} + @endif +
+
+
+ + +
+
+
+
+ + +
+ @if($errors->has('contentURL')) + {{ $errors->first('contentURL') }} + @endif +
+
+ + +
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/course/material/edit.blade.php b/resources/views/backend/course/material/edit.blade.php new file mode 100644 index 0000000..5c870b9 --- /dev/null +++ b/resources/views/backend/course/material/edit.blade.php @@ -0,0 +1,124 @@ +@extends('backend.layouts.app') +@section('title', 'Edit Course Material Material') + +@push('styles') + + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Edit Course Material

+
+
+ +
+ +
+
+
+
+
Basic Info
+
+
+
+ @csrf + @method('PATCH') + +
+
+
+ + +
+ @if($errors->has('materialTitle')) + {{ $errors->first('materialTitle') }} + @endif +
+
+
+ + +
+ @if($errors->has('courseId')) + {{ $errors->first('courseId') }} + @endif +
+
+
+ + +
+ @if($errors->has('materialType')) + {{ $errors->first('materialType') }} + @endif +
+
+
+ + +
+ @if($errors->has('contentURL')) + {{ $errors->first('contentURL') }} + @endif +
+
+ + +
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/course/material/index.blade.php b/resources/views/backend/course/material/index.blade.php new file mode 100644 index 0000000..66f48c5 --- /dev/null +++ b/resources/views/backend/course/material/index.blade.php @@ -0,0 +1,113 @@ +@extends('backend.layouts.app') +@section('title', 'Course Material List') + +@push('styles') + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Course Material List

+
+
+ +
+ +
+ +
+
+
+
+
+

All Course Materials List

+ + Add new +
+
+
+ + + + + + + + + + + + + @forelse ($material as $m) + + + + + + + + + @empty + + + + @endforelse + +
{{__('#')}}{{__('Title')}}{{__('Course')}}{{__('Material Type')}}{{__('Content Url')}}{{__('Action')}}
{{$m->id}}{{$m->title}}{{$m->course?->title_en}} + {{ $m->type == 'video' ? __('Video') : ($d->type == 'Document' ? + __('Paid') : __('Quiz')) }} + {{$m->content_url}} + + +
+ @csrf + @method('DELETE') +
+
No Course Material Found
+
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + +@endpush \ No newline at end of file