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:
@@ -16,6 +16,18 @@ class Course extends Model
|
||||
return $this->belongsTo('App\User');
|
||||
}
|
||||
|
||||
public function instructor()
|
||||
{
|
||||
if (\App\User::find($this->user_id))
|
||||
{
|
||||
return \App\User::find($this->user_id)->fullname();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
public function event()
|
||||
{
|
||||
return $this->belongsTo('App\Event');
|
||||
|
||||
@@ -142,6 +142,14 @@ class EventController extends Controller
|
||||
}
|
||||
|
||||
$course->save();
|
||||
|
||||
$ocom = \App\OCOM::where('ocom','=',request('ocom_n'.$l.'_p'.$p))->first();
|
||||
if ($ocom != null)
|
||||
{
|
||||
$foo = $ocom->courses();
|
||||
$foo->push($course);
|
||||
$ocom->saveCourses($foo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ class OCOMController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
return view('admin.ocom.index',['ocoms' => OCOM::all()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -640,6 +640,18 @@ X20,\"Participer à des activités
|
||||
|
||||
$newocom->ocom = $ocom[0];
|
||||
$newocom->oren = $oren[0];
|
||||
|
||||
if ($newocom->ocom[0] == 'C' || $newocom->ocom[0] == 'c')
|
||||
{
|
||||
$newocom->complementary = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$newocom->complementary = false;
|
||||
}
|
||||
|
||||
$newocom->course_id = '';
|
||||
|
||||
$newocom->objectif_competence = $obj_competence;
|
||||
$newocom->objectif_rendement = $orens[$oren[0]];
|
||||
$newocom->save();
|
||||
@@ -662,12 +674,12 @@ X20,\"Participer à des activités
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\OCOM $oCOM
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param $OCOM
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function show(OCOM $oCOM)
|
||||
public function show($OCOM)
|
||||
{
|
||||
//
|
||||
return view('admin.ocom.show',['ocom' => OCOM::find($OCOM)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
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