Skip to content

Commit

Permalink
Add models in orif/plafor/Models
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierViret committed May 6, 2021
2 parents 6b948d9 + 54a9755 commit 6ec91ff
Show file tree
Hide file tree
Showing 12 changed files with 322 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/Config/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Autoload extends AutoloadConfig
'Config' => APPPATH . 'Config',
'Common' => ROOTPATH.'orif/common',
'Welcome' => ROOTPATH.'orif/welcome',
'User' => ROOTPATH.'orif/user'
'User' => ROOTPATH.'orif/user',
'Plafor' => ROOTPATH.'orif/plafor'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage": "https://codeigniter.com",
"license": "MIT",
"require": {
"php": "^7.3||^8.0",
"php": "^7.4||^8.0",
"ext-curl": "*",
"ext-intl": "*",
"ext-json": "*",
Expand Down
19 changes: 19 additions & 0 deletions orif/plafor/Models/acquisitionLevelModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Plafor\Models;
use CodeIgniter\Model;

class AcquisitionLevelModel extends Model{

protected $table='comment';
protected $primaryKey='id';
protected $allowedFields=['name'];

}






?>
57 changes: 57 additions & 0 deletions orif/plafor/Models/acquisitionStatusModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Plafor\Models;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;
use CodeIgniter\Validation\ValidationInterface;

class AcquisitionStatusModel extends Model{

protected $table='acquisition_status';
protected $primaryKey='id';
protected $allowedFields=['fk_objective','fk_user_course','fk_acquisition_level'];
private ObjectiveModel $objectiveModel;
private UserCourseModel $userCourseModel;
private AcquisitionLevelModel $acquisitionLevelModel;

public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);
}

/**
* @param $acquisitionStatut /the array obtained from this model
* @return array
*/
public function getObjective($acquisitionStatut){
$this->objectiveModel = new ObjectiveModel();
return $this->objectiveModel->find($acquisitionStatut['fk_objective']);

}
/**
* @param $acquisitionStatut /the array obtained from this model
* @return array
*/
public function getUserCourse($acquisitionStatut){
$this->userCourseModel=new UserCourseModel();
return $this->userCourseModel->find($acquisitionStatut['fk_user_course']);

}
/**
* @param $acquisitionStatut /the array obtained from this model
* @return array
*/
public function getAcquisitionLevel($acquisitionStatut){
if ($this->acquisitionLevelModel==null)
$this->acquisitionLevelModel=new AcquisitionLevelModel();
return $this->acquisitionLevelModel->find($acquisitionStatut['fk_acquisition_level']);

}
}






?>
42 changes: 42 additions & 0 deletions orif/plafor/Models/commentModel copy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Plafor\Models;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;
use CodeIgniter\Validation\ValidationInterface;
use User\Models\User_model;

class CommentModel extends Model{

protected $table='comment';
protected $primaryKey='id';
protected $allowedFields=['fk_trainer','fk_acquisition_status','comment','date_creation'];
private User_model $userModel;
private AcquisitionStatusModel $acquisitionStatusModel;
/**To do
* Add method to get trainer and acquisition_status
*/
public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);


}

public function getTrainer($comment){
if ($this->userModel==null)
$this->userModel=new User_model();
return $this->userModel->find($comment['fk_trainer']);
}
public function getAcquisitionStatus($comment){
$this->acquisitionStatusModel=new AcquisitionStatusModel();
return $this->acquisitionStatusModel->find($comment['fk_acquisition_status']);
}
}






?>
40 changes: 40 additions & 0 deletions orif/plafor/Models/competenceDomainModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Plafor\Models;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;
use CodeIgniter\Validation\ValidationInterface;

class CompetenceDomainModel extends Model{

protected $table='competence_domain';
protected $primaryKey='id';
protected $allowedFields=['fk_course_plan','symbol','name','archive'];
protected $useSoftDeletes=true;
protected $deletedField='archive';
private CoursePlanModel $coursePlanModel;
/**To do
* Add method to get course_plan
*/

public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);

}

public function getCoursePlan($competenceDomain){
if ($this->coursePlanModel==null)
$this->coursePlanModel=new CoursePlanModel();

return $this->coursePlanModel->find($competenceDomain['fk_course_plan']);

}
}






?>
17 changes: 17 additions & 0 deletions orif/plafor/Models/coursePlanModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Plafor\Models;

use CodeIgniter\Model;

class CoursePlanModel extends Model{
protected $table='course_plan';
protected $primaryKey='id';
protected $allowedFields=['formation_number','official_name','date_begin'];
protected $useSoftDeletes=true;
protected $deletedField='archive';


}


?>
30 changes: 30 additions & 0 deletions orif/plafor/Models/objectiveModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php


namespace Plafor\Models;


use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Validation\ValidationInterface;

class ObjectiveModel extends \CodeIgniter\Model
{
protected $table='objective';
protected $primaryKey='id';
protected $allowedFields=['fk_operational_competence','symbol','taxonomy','name'];
protected $useSoftDeletes=true;
protected $deletedField='archive';
private OperationalCompetenceModel $operationalCompetenceModel;

public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);
}
public function getOperationalCompetence($objective){
if ($this->operationalCompetenceModel==null)
$this->operationalCompetenceModel=new OperationalCompetenceModel();
return $this->operationalCompetenceModel->find($objective['fk_operational_competence']);
}


}
28 changes: 28 additions & 0 deletions orif/plafor/Models/operationalCompetenceModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php


namespace Plafor\Models;


use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Validation\ValidationInterface;

class OperationalCompetenceModel extends \CodeIgniter\Model
{
protected $table='operational_competence';
protected $primaryKey='id';
protected $allowedFields=['fk_competence_domain','name','symbol','methodologic','social','personal'];
protected $useSoftDeletes='true';
protected $deletedField='archive';
private CompetenceDomainModel $competenceDomainModel;
public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);
}
public function getCompetenceDomain($operationalCompetence){
if ($this->competenceDomainModel==null)
$this->competenceDomainModel=new CompetenceDomainModel();
return $this->competenceDomainModel->find($operationalCompetence['fk_competence_domain']);
}

}
32 changes: 32 additions & 0 deletions orif/plafor/Models/trainerApprenticeModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php


namespace Plafor\Models;


use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Validation\ValidationInterface;
use User\Models\User_model;

class TrainerApprenticeModel extends \CodeIgniter\Model
{
protected $table='trainer_apprentice';
protected $primaryKey='id';
protected $allowedFields=['fk_trainer','fk_apprentice'];
private User_model $userModel;
public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);
}
public function getTrainer($trainerApprentice){
if ($this->userModel==null)
$this->userModel=new User_model();
return $this->userModel->find($trainerApprentice['fk_trainer']);
}
public Function getApprentice($trainerApprentice){
if ($this->userModel==null)
$this->userModel=new User_model();
return $this->userModel->find($trainerApprentice['fk_apprentice']);

}
}
42 changes: 42 additions & 0 deletions orif/plafor/Models/userCourseModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php


namespace Plafor\Models;


use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Validation\ValidationInterface;
use User\Models\User_model;

class UserCourseModel extends \CodeIgniter\Model
{
protected $table='user_course';
protected $primaryKey='id';
protected $allowedFields=['fk_user','fk_course_plan','fk_status','date_begin','date_end'];
private User_model $userModel;
private CoursePlanModel $coursePlanModel;
private AcquisitionStatusModel $acquisitionStatusModel;
/** create function to get user, course plan and status */
public function __construct(ConnectionInterface &$db = null, ValidationInterface $validation = null)
{
parent::__construct($db, $validation);

}
public function getUser($userCourse){
if ($this->userModel==null)
$this->userModel=new User_model();
return $this->userModel->find($userCourse['fk_user']);
}
public function getCoursePlan($userCourse){
if ($this->coursePlanModel==null)
$this->coursePlanModel=new CoursePlanModel();
return $this->coursePlanModel->find($userCourse['fk_course_plan']);
}
public function getStatut($userCourse){
if ($this->acquisitionStatusModel==null)
$this->acquisitionStatusModel=new AcquisitionStatusModel();
return $this->acquisitionStatusModel->find($userCourse['fk_status']);
}


}
12 changes: 12 additions & 0 deletions orif/plafor/Models/userCourseStatusModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php


namespace Plafor\Models;


class UserCourseStatusModel extends \CodeIgniter\Model
{
protected $table='user_course_status';
protected $primaryKey='id';
protected $allowedFields=['name'];
}

0 comments on commit 6ec91ff

Please sign in to comment.