D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
school.dentostock.com
/
app
/
View
/
Components
/
Filename :
Course.php
back
Copy
<?php namespace App\View\Components; use App\SmCourse; use Closure; use Illuminate\Contracts\View\View; use Illuminate\View\Component; class Course extends Component { public $count; public $column; public $sorting; /** * Create a new component instance. */ public function __construct($count = 3, $column = 4, $sorting = 'asc') { $this->count = $count; $this->column = $column; $this->sorting = $sorting; } /** * Get the view / contents that represent the component. */ public function render(): View|Closure|string { $courses = SmCourse::query(); $courses->where('school_id', app('school')->id)->with('courseCategory'); if($this->sorting =='asc'){ $courses->orderBy('id','asc'); } elseif($this->sorting =='desc'){ $courses->orderBy('id','desc'); } else{ $courses->inRandomOrder(); } $courses = $courses->take($this->count)->get(); return view('components.'.activeTheme().'.course', compact('courses')); } }