function dataExpertCategories($id, $status = 'active')
 {
     if (isset($id)) {
         $categories = ExpertCategory::where('expert_id', $id)->with('category')->with('subcategory')->where('status', 'active')->get();
         if (isset($categories)) {
             return json_encode(array('message' => 'found', 'categories' => $categories->toArray()));
         } else {
             return json_encode(array('message' => 'empty'));
         }
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
 public function removeExpertCategory($id)
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $expertCategory = ExpertCategory::find($id);
     if (isset($expertCategory)) {
         $expertCategory->status = 'removed';
         $expertCategory->save();
         return json_encode(array('message' => 'done'));
     } else {
         return json_encode(array('message' => 'invalid'));
     }
 }
Example #3
0
 private function subscribeExpertToCategories($categories, User $user)
 {
     if (!is_array($categories)) {
         return;
     }
     foreach ($categories as $categoryid) {
         $category = CategoryPeer::retrieveByPK($categoryid);
         if (!$category) {
             continue;
         }
         $expertcat = new ExpertCategory();
         $expertcat->setUser($user);
         $expertcat->setCategory($category);
         $expertcat->save();
     }
 }
Example #4
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      ExpertCategory $value A ExpertCategory object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(ExpertCategory $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }