app/Http/Controllers/ProductController.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)
    {
        $data = $request->validate([
            'name'  => 'required|min:3',
            'desc'  => 'required|',
            'price' => 'required|alpha_num',
            'stock' => 'required|alpha_num'
        ]);
        $response = Http::withToken($this->_tokenUser())->post('http:localhost:8002/products/create', $data);
        if ($response->json()) {
            return redirect()->route('products')->with([
                'class' => 'success',
                'icon' => 'fas fa-check',
                'message' => $response->json()['message']
            ]);
        } else {
            return redirect()->route('products')->with([
                'class' => 'danger',
                'icon' => 'fas fa-ban',
                'message' => $response->json()['message']
            ]);
        }
    }
public function store ( Request $ request ) { $ data = $ request -> validate ( [ 'name' => 'required|min:3' , 'desc' => 'required|' , 'price' => 'required|alpha_num' , 'stock' => 'required|alpha_num' ] ) ; $ response = Http :: withToken ( $ this -> _tokenUser ( ) ) -> post ( 'http://localhost:8002/products/create' , $ data ) ; if ( $ response -> json ( ) ) { return redirect ( ) -> route ( 'products' ) -> with ( [ 'class' => 'success' , 'icon' => 'fas fa-check' , 'message' => $ response -> json ( ) [ 'message' ] ] ) ; } else { return redirect ( ) -> route ( 'products' ) -> with ( [ 'class' => 'danger' , 'icon' => 'fas fa-ban' , 'message' => $ response -> json ( ) [ 'message' ] ] ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//