mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
Debut BD Cours
This commit is contained in:
24
app/OCOM.php
24
app/OCOM.php
@@ -6,5 +6,27 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OCOM extends Model
|
||||
{
|
||||
//
|
||||
public function courses()
|
||||
{
|
||||
$courses_id = explode(',',$this->course_id);
|
||||
$courses = collect();
|
||||
foreach ($courses_id as $course_id)
|
||||
{
|
||||
$courses->push(\App\Course::find($course_id));
|
||||
}
|
||||
return $courses;
|
||||
}
|
||||
|
||||
public function saveCourses($courses)
|
||||
{
|
||||
$courses_id = [];
|
||||
foreach ($courses as $cours)
|
||||
{
|
||||
if ($cours != null){
|
||||
array_push($courses_id,$cours->id);
|
||||
}
|
||||
}
|
||||
$this->course_id = implode(',',$courses_id);
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user