Ejemplo n.º 1
0
 public function addItem()
 {
     $v = Input::get('v');
     $c = Input::get('c');
     $v = trim($v);
     if (strlen($v) == 0) {
         return response()->json(['status' => 0]);
     }
     $v = substr($v, 0, 255);
     if ((int) $c < 1) {
         return response()->json(['status' => 1]);
     }
     $status = Parts::addItem($v, $c);
     return response()->json(['status' => $status]);
 }
Ejemplo n.º 2
0
 public static function addItem($val, $cat_id)
 {
     $query = Parts::select('id')->where('part', '=', $val)->get();
     if (count($query) > 0) {
         return 2;
     }
     if (Auth::user()) {
         $user_id = Auth::user()->id;
     } else {
         $user_id = 0;
     }
     $ins = DB::table('parts')->insert(['part' => $val, 'add_user_id' => $user_id, 'category_id' => $cat_id]);
     if ($ins) {
         return 3;
     } else {
         return 4;
     }
     // error
 }