Exemplo n.º 1
0
 /**
  * @create提交动作
  */
 public function store()
 {
     //数据验证
     //数据验证
     $rules = array('name' => 'required|min:2', 'desc' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     //规则校验
     if ($validator->fails()) {
         return Redirect::route('cate.create')->withErrors($validator)->withInput();
     }
     //检查类名唯一性,不同用户的分类可以相同
     $name = Input::get('name');
     $num = Cate::where('name', $name)->where('uid', Auth::id())->count();
     if ($num == 0) {
         //类别入库
         Cate::create(array('name' => Input::get('name'), 'uid' => Input::get('uid'), 'desc' => Input::get('desc')));
         return Redirect::route('cate.create')->with('success', '添加成功!');
     } else {
         return Redirect::route('cate.create')->withInput()->with('error', '类名不能重复');
     }
 }
Exemplo n.º 2
0
 public function categoryStore()
 {
     // print_r(Input::all() );
     // $all = Input::all();
     // print_r($all);
     $name = Input::get("name");
     $type = Input::get("type");
     // $$valute;
     if ($name) {
         Cate::create(array('name' => $name, 'type' => $type));
         // $category = new Category;
         //
         // $category->name = 'John';
         //
         // $category->save();
         //
         return Redirect::to('categories')->withInput()->with('success', '新增成功');
     } else {
         return Redirect::to('categories/create')->withInput()->with('error', '新增失敗');
     }
 }
Exemplo n.º 3
0
 public function typeStore()
 {
     $all = Input::all();
     $rate_id = $all["rate_id"];
     $type_id = $all["type"];
     $name = $all["name"];
     unset($all["_token"]);
     // print_r($all);
     // $update_data=array('name' => $name,'type' => $type);
     if (!empty($name)) {
         Cate::create($all);
     }
     return Redirect::to('rate/details_list/' . $rate_id)->withInput()->with('success', '新增成功');
 }