app/Http/Controllers/MassController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $check = KhoiLuong::all();
        $count = 0;
        $data = new KhoiLuong();
        $data->khoiLuong = $request->input('khoiLuong'); 
        $trangThai=0;
        if($request->has('trangThai')) 
        {
            $trangThai = $request->input('trangThai');
        }
        $data->trangThai = $trangThai;
        foreach ($check as $ch){
            if($data->khoiLuong == $ch->khoiLuong){
                $count++;
            }
        }
        if($count==0){
            $data->save();
            return redirect()->route('admin.mass.index')->with('alert','thong bao'); 
        }
        else
            return redirect()->route('admin.mass.create')->with('alert','thong bao');
    }
public function store ( Request $ request ) { $ check = KhoiLuong :: all ( ) ; $ count = 0 ; $ data = new KhoiLuong ( ) ; $ data -> khoiLuong = $ request -> input ( 'khoiLuong' ) ; $ trangThai = 0 ; if ( $ request -> has ( 'trangThai' ) ) { $ trangThai = $ request -> input ( 'trangThai' ) ; } $ data -> trangThai = $ trangThai ; foreach ( $ check as $ ch ) { if ( $ data -> khoiLuong == $ ch -> khoiLuong ) { $ count ++ ; } } if ( $ count == 0 ) { $ data -> save ( ) ; return redirect ( ) -> route ( 'admin.mass.index' ) -> with ( 'alert' , 'thong bao' ) ; } else return redirect ( ) -> route ( 'admin.mass.create' ) -> with ( 'alert' , 'thong bao' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//nhận nhập khoiLuong trong input //has(name-input) //has-kiểm tra tồn tại hay ko //điều hướng đến foder category - flie index