public function run()
 {
     $faker = Faker\Factory::create();
     //Categories::truncate();
     for ($i = 0; $i < 10; $i++) {
         $category = Categories::create(array('name' => $faker->word, 'description' => $faker->text));
     }
 }
function categories_create_form_submit($data)
{
    $data['church_id'] = $_SESSION['log_church_id'];
    $error = categories_validate($data);
    if (!empty($error)) {
        return FALSE;
    }
    $categories = new Categories();
    $response = $categories->create($data);
    if ($response['id'] > 0) {
        return categories_list($response['id']);
    } else {
        return false;
    }
}
示例#3
0
 public static function create($data)
 {
     $response = new Response();
     try {
         $data = json_decode($data, true);
         /** @var Products $products */
         $category = new Categories();
         $category->setAttributes($data);
         $response->data = $category->create();
         $response->status = $response::STATUS_CREATED;
     } catch (Exception $e) {
         $response->setException($e);
     } finally {
         return $response->toArray();
     }
 }
示例#4
0
 function pyrusAddCategory($frontend, $args)
 {
     if (!isset($this->channel)) {
         throw new Exception('Unknown channel, run the ' . 'scs-create command first');
     }
     $this->getSCS();
     $categories = new Categories($this->channel);
     $categories->create($args['category'], $args['description']);
     $category->savePackagesInfo($args['category']);
     echo "Added category ", $args['category'], "\n";
 }
示例#5
0
 public function postAddCategory()
 {
     $inputData = Input::get('formData');
     parse_str($inputData, $formFields);
     $formData = array('category_name' => $formFields['category_name'], 'category_slug' => $formFields['category_slug']);
     $rules = array('category_name' => 'required|unique:categories', 'category_slug' => 'required|unique:categories');
     $validator = Validator::make($formData, $rules);
     if ($validator->fails()) {
         return Response::json(array('fail' => true, 'errors' => $validator->getMessageBag()->toArray()));
     } else {
         //hash it now
         if (Categories::create($formData)) {
             return Response::json(array('success' => true));
         }
     }
 }