예제 #1
0
 /**
  * Create new field value
  * @param  array $data
  * @return mixed
  */
 public function create($data)
 {
     // First validate the input
     if ($this->validation->passes($data)) {
         // Prepare slug
         $slug = Str::slug(array_get($data, 'slug'));
         if (!$slug) {
             $slug = Str::slug(array_get($data, 'title'));
         }
         // Save term
         $term = new Term(array('title' => array_get($data, 'title'), 'slug' => $slug, 'taxonomy_id' => array_get($data, 'taxonomy_id'), 'body' => array_get($data, 'body'), 'image' => array_get($data, 'image')));
         $term->save();
         return $term->id;
     }
     // Set errors
     $this->errors = $this->validation->errors();
     return false;
 }