示例#1
0
 public function update($id)
 {
     $volunteer = Volunteer::getVolunteer($id);
     $newbio = Request::input('bio');
     $volunteer->updateVolunteerBio($newbio);
     return "True";
 }
示例#2
0
 /**
  * Creates a form model given a token.
  *
  * @param int   $id     The user ID.
  * @param array $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($id, $config = [])
 {
     // Volunteer can be new or have an existing entry.
     $this->_volunteer = Volunteer::findOne($id);
     if (!$this->_volunteer) {
         $this->_volunteer = new Volunteer();
         $this->_volunteer->accountID = $id;
     } else {
         // Initialise form values.
         foreach ($this::$interestBits as $key => $value) {
             if ($key & $this->_volunteer->interests) {
                 $this->interests[] = $key;
             }
         }
         foreach ($this::$availabilityBits as $key => $value) {
             if ($key & $this->_volunteer->availability) {
                 $this->availability[] = $key;
             }
             if ($key & $this->_volunteer->experience) {
                 $this->experience[] = $key;
             }
         }
         $this->daysAvailable = $this->_volunteer->daysAvailable;
         $this->skills = $this->_volunteer->skills;
         $this->mobile = User::findOne($id)->details->mobile;
     }
     parent::__construct($config);
 }
示例#3
0
 public static function all()
 {
     // SQL
     $sql = "select * from volunteer";
     // Execute
     $rows = DB::select($sql);
     $volunteers = [];
     foreach ($rows as $row) {
         $volunteers[] = Volunteer::createVolunteerFromRow($row);
     }
     return $volunteers;
 }