Пример #1
0
 /**
  * Create or update a Formation.
  *
  * @param  App\Models\Formation $formation
  * @param  array  $inputs
  * @param  bool   $user_id
  * @return App\Models\Formation
  */
 public function save($inputs, $cv_id = null)
 {
     if (isset($inputs['intitule'])) {
         $this->model->intitule = $inputs['intitule'];
     }
     if (isset($inputs['diplome'])) {
         $this->model->diplome = $inputs['diplome'];
     }
     if (isset($inputs['date_dedut'])) {
         $this->model->date_dedut = $inputs['date_dedut'];
     }
     if (isset($inputs['date_fin'])) {
         $this->model->date_fin = $inputs['date_fin'];
     }
     if (isset($inputs['mention'])) {
         $this->model->mention = $inputs['mention'];
     }
     if (isset($inputs['cv_id'])) {
         $this->cv = Cv::find(intval($inputs['cv_id']));
         if ($this->cv != null) {
             $this->model->cv_id = $this->cv->id;
         }
     }
     if (isset($inputs['etablissement_id'])) {
         $this->etablissement = Etablissement::find(intval($inputs['etablissement_id']));
         if ($this->etablissement != null) {
             $this->model->etablissement_id = $this->etablissement->id;
         }
     }
     $this->model->save();
     $this->model->etablissement = $this->etablissement;
     return $this->model;
 }
Пример #2
0
 /**
  * Get all Etablissements.
  *
  * @return Illuminate\Support\Collection
  */
 public function all()
 {
     return Etablissement::get();
 }
Пример #3
0
 /**
  * Update a model.
  *
  * @param  array  $inputs
  * @param  $id
  * @return void
  */
 public function update($inputs, $id)
 {
     $this->model = Etablissement::find($id);
     return $this->save($inputs);
 }
Пример #4
0
 /**
  * Get Formation collection.
  *
  * @param  int     $n
  * @param  int     $user_id
  * @param  string  $orderby
  * @param  string  $direction
  * @return Illuminate\Support\Collection
  */
 public function index($n, $cv_id = null)
 {
     $query = $this->model->select('Formations.id', 'Formations.intitule', 'Formations.diplome', 'Formations.mention', 'Formations.cv_id', 'Formations.etablissement_id')->join('cvs', 'cvs.id', '=', 'Formations.cv_id');
     if ($cv_id) {
         $query->where('cv_id', $cv_id);
     }
     $query->paginate($n);
     $var = $query->paginate($n);
     foreach ($var as $value) {
         $this->etablissement = Etablissement::find($value->etablissement_id);
         $formations[] = ["id" => $value->id, "intitule" => $value->intitule, "diplome" => $value->diplome, "date_debut" => $value->date_debut, "date_fin" => $value->date_fin, "mention" => $value->mention, "etablissement" => $this->etablissement];
     }
     return ["formations" => $formations];
 }