public function __construct($scenario = '', $id = null, $checkApproved = false) { if ($scenario == 'view' && $id != null) { $this->workshop = Workshop::getWorkshop($id, $checkApproved); //model()->with('postItem')->findByPk($id); $this->workshopFile = $this->workshop->workshop_file; if ($this->workshop != null) { $this->postItem = $this->workshop->postItem; } else { throw new CHttpException(400, 'Cannot found the event post.'); } } else { $this->_new(); } }