app/Http/Controllers/AdminController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function createProduct(Request $request, $nameShow)
    {
        if ($nameShow == 'addproduct') {
            $name = $request->post('name');
            $manu_id = $request->post('manu');
            $type_id = $request->post('type');
            $price = $request->post('price');
            $desc = $request->post('desc');
            $feature = $request->post('feature');
            $chip = $request->post('Chip');
            $ram = $request->post('Ram');
            $Capacity = $request->post('Capacity');
            $quantity = $request->post('quantity');
            $HDH = $request->post('HDH');
            $origin = $request->post('origin');
            $request->hasFile('image');
            $img = $request->image;
            $Location = "..\public\assets\pages\img\products";
            $imageName = $img->getClientOriginalName();
            if(!@is_array(getimagesize($Location.$imageName))){
                $img->move($Location, $img->getClientOriginalName());
                DB::table('product')->insert([
                    ['name' => $name, 'sale_price' => 0, 'manu_id' => $manu_id, 'type_id' => $type_id, 'price' => $price, 'image' => $imageName, 'description' => $desc, 'feature' => $feature, 'quantity' => $quantity, 'status' => 1, 'Ram' => $ram, 'Capacity' => $Capacity, 'HDH' => $HDH, 'chip' => $chip, 'origin' => $origin]
                ]);
            } else {
                $message = "Lỗi chọn không phải ảnh";
                echo "<script type='text/javascript'>alert('$message');</script>";
            }
        } elseif ($nameShow == 'addManu') {
            $name = $request->post('name');
            $request->hasFile('image');
            $img = $request->image;
            $Location = "..\public\assets\pages\img\brands";
            $imageName = $img->getClientOriginalName();
            if(!@is_array(getimagesize($Location.$imageName))){
                $img->move($Location, $img->getClientOriginalName());
            DB::table('manufactures')->insert([
              ['manu_name'=>$name, 'image'=>$imageName]
            ]);
            } else {
                $message = "Lỗi chọn không phải ảnh";
                echo "<script type='text/javascript'>alert('$message');</script>";
            }
        }else {
            $name = $request->post('name');
            DB::table('protypes')->insert([
              ['type_name'=>$name]
            ]);
        }
        $manufactures = Manufactures::all();
        $products = DB::table('product')
            ->join('manufactures', 'product.manu_id', '=', 'manufactures.id')
            ->join('protypes', 'product.type_id', '=', 'protypes.id')
            ->select('product.*', 'manufactures.manu_name', 'protypes.type_name')
            ->get();
        $protypes = Protype::all();
        return view($nameShow)->with('getProducts', $products)
            ->with('getProtypes', $protypes)
            ->with('getManufactures', $manufactures);
    }
public function createProduct ( Request $ request , $ nameShow ) { if ( $ nameShow == 'addproduct' ) { $ name = $ request -> post ( 'name' ) ; $ manu_id = $ request -> post ( 'manu' ) ; $ type_id = $ request -> post ( 'type' ) ; $ price = $ request -> post ( 'price' ) ; $ desc = $ request -> post ( 'desc' ) ; $ feature = $ request -> post ( 'feature' ) ; $ chip = $ request -> post ( 'Chip' ) ; $ ram = $ request -> post ( 'Ram' ) ; $ Capacity = $ request -> post ( 'Capacity' ) ; $ quantity = $ request -> post ( 'quantity' ) ; $ HDH = $ request -> post ( 'HDH' ) ; $ origin = $ request -> post ( 'origin' ) ; $ request -> hasFile ( 'image' ) ; $ img = $ request -> image ; $ Location = " ..\public\assets\pages\img\products " ; $ imageName = $ img -> getClientOriginalName ( ) ; if ( ! @ is_array ( getimagesize ( $ Location . $ imageName ) ) ) { $ img -> move ( $ Location , $ img -> getClientOriginalName ( ) ) ; DB :: table ( 'product' ) -> insert ( [ [ 'name' => $ name , 'sale_price' => 0 , 'manu_id' => $ manu_id , 'type_id' => $ type_id , 'price' => $ price , 'image' => $ imageName , 'description' => $ desc , 'feature' => $ feature , 'quantity' => $ quantity , 'status' => 1 , 'Ram' => $ ram , 'Capacity' => $ Capacity , 'HDH' => $ HDH , 'chip' => $ chip , 'origin' => $ origin ] ] ) ; } else { $ message = " Lỗi chọn không phải ảnh"; echo " <script type='text/javascript'>alert(' $ message ');</script> " ; } } elseif ( $ nameShow == 'addManu' ) { $ name = $ request -> post ( 'name' ) ; $ request -> hasFile ( 'image' ) ; $ img = $ request -> image ; $ Location = " ..\public\assets\pages\img\brands " ; $ imageName = $ img -> getClientOriginalName ( ) ; if ( ! @ is_array ( getimagesize ( $ Location . $ imageName ) ) ) { $ img -> move ( $ Location , $ img -> getClientOriginalName ( ) ) ; DB :: table ( 'manufactures' ) -> insert ( [ [ 'manu_name' => $ name , 'image' => $ imageName ] ] ) ; } else { $ message = " Lỗi chọn không phải ảnh"; echo " <script type='text/javascript'>alert(' $ message ');</script> " ; } } else { $ name = $ request -> post ( 'name' ) ; DB :: table ( 'protypes' ) -> insert ( [ [ 'type_name' => $ name ] ] ) ; } $ manufactures = Manufactures :: all ( ) ; $ products = DB :: table ( 'product' ) -> join ( 'manufactures' , 'product.manu_id' , '=' , 'manufactures.id' ) -> join ( 'protypes' , 'product.type_id' , '=' , 'protypes.id' ) -> select ( 'product.*' , 'manufactures.manu_name' , 'protypes.type_name' ) -> get ( ) ; $ protypes = Protype :: all ( ) ; return view ( $ nameShow ) -> with ( 'getProducts' , $ products ) -> with ( 'getProtypes' , $ protypes ) -> with ( 'getManufactures' , $ manufactures ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
//