added course count by category in home page
Cette révision appartient à :
Parent
6ba10c9bba
révision
2dcd386557
@ -15,7 +15,7 @@ class Course extends Model
|
||||
|
||||
public function courseCategory()
|
||||
{
|
||||
return $this->belongsTo(CourseCategory::class, 'category_id', 'id');
|
||||
return $this->belongsTo(CourseCategory::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
public function instructor()
|
||||
|
||||
@ -12,4 +12,4 @@ class CourseCategory extends Model
|
||||
public function course(){
|
||||
return $this->hasMany(Course::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public function up(): void
|
||||
$table->string('title_bn')->nullable();
|
||||
$table->text('description_en')->nullable();
|
||||
$table->text('description_bn')->nullable();
|
||||
$table->unsignedBigInteger('category_id')->index();
|
||||
$table->unsignedBigInteger('course_category_id')->index();
|
||||
$table->unsignedBigInteger('instructor_id')->index();
|
||||
$table->enum('type', ['free', 'paid', 'subscription'])->default('paid');
|
||||
$table->decimal('price', 10, 2)->default(0.00)->nullable();
|
||||
@ -40,7 +40,7 @@ public function up(): void
|
||||
|
||||
// Foreign key constraints
|
||||
$table->foreign('instructor_id')->references('id')->on('instructors')->onDelete('cascade');
|
||||
$table->foreign('category_id')->references('id')->on('course_categories')->onDelete('cascade');
|
||||
$table->foreign('course_category_id')->references('id')->on('course_categories')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,10 @@ class="img-fluid" />
|
||||
<div class="browse-categories__wrapper position-relative">
|
||||
<div class="categories--box">
|
||||
@forelse ($category as $cat)
|
||||
@php
|
||||
// Fetch the count of courses for each category
|
||||
$courseCount = $cat->course()->count();
|
||||
@endphp
|
||||
<div class="browse-categories-item default-item-one mb-2">
|
||||
<div class="browse-categories-item-icon">
|
||||
<div class="categories-one default-categories">
|
||||
@ -59,7 +63,7 @@ class="img-fluid" />
|
||||
</div>
|
||||
<div class="browse-categories-item-text">
|
||||
<h6 class="font-title--card"><a href="#">{{$cat->category_name}}</a></h6>
|
||||
<p>587 Courses</p>
|
||||
<p>{{ $courseCount }} Courses</p>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
@ -77,7 +81,7 @@ class="img-fluid" />
|
||||
class="img-fluid shape-01" />
|
||||
<img src="{{asset('public/frontend/dist/images/shape/line01.png')}}" alt="shape" class="img-fluid shape-02" />
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- Popular Courses Starts Here -->
|
||||
<section class="section section--bg-offwhite-three featured-popular-courses main-popular-course">
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user