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