app/Http/Controllers/SupplierController.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)
    {
        $checkIfExist = Supplier::where('name',$request->input('name'))->count();
        if ($checkIfExist == 1){
            return back()->with('error','Supplier Already Exist');
        }else{
            $supplier = new Supplier();
            $supplier->name = $request->input('name');
            $supplier->phone_number = $request->input('phone_number');
            $supplier->email = $request->input('email');
            $supplier->save();
            return redirect('/drugs')
                ->with('success','New Supplier Added');
        }
    }
public function store ( Request $ request ) { $ checkIfExist = Supplier :: where ( 'name' , $ request -> input ( 'name' ) ) -> count ( ) ; if ( $ checkIfExist == 1 ) { return back ( ) -> with ( 'error' , 'Supplier Already Exist' ) ; } else { $ supplier = new Supplier ( ) ; $ supplier -> name = $ request -> input ( 'name' ) ; $ supplier -> phone_number = $ request -> input ( 'phone_number' ) ; $ supplier -> email = $ request -> input ( 'email' ) ; $ supplier -> save ( ) ; return redirect ( '/drugs' ) -> with ( 'success' , 'New Supplier Added' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .