public static function post($post) { $post['alias'] = isset($post['alias']) ? $post['alias'] : ''; $validator = self::check($post); if ($validator->fails()) { return error(900, ['validateError' => $validator->messages()]); } else { if (trim($post['alias']) == '') { $post['alias'] = $post['title']; } } $row = Self::create($post); if (self::where('alias', $row->alias)->count() > 1) { $row->alias .= '_' . uniqid(); } $row->save(); return $row; }
function add_bgimages($data) { $data = array('path' => $data['path'], 'full_path' => $data['full_path'], 'description' => $data['description'], 'title' => $data['title']); Self::create($data); }