app/Http/Controllers/CentralController.php
/*
     * Save central office or head of district
     */
Save central office or head of district
Save central office or head of district
public function store(Request $request){
        try{
            if(!$request->input('central_name') )
                throw new Exception("Central name is required!");
            $centralOffice = new CentralOffice();
            $centralOffice->central_name = $request->input('central_name');
            $centralOffice->central_details = $request->input('central_details');
            if(!$centralOffice->save())
                throw new Exception("Critical error when save central office data!");
            $where = ['central_office_id'=>$centralOffice->id,'role'=>1];
            $centralOffice->head = TermRelation::findMyAdmin($where);
            return ['success'=>true, 'message'=>'Cetnral office save success', 'data'=>$centralOffice];
        }catch (Exception $e){
            return ['success'=>false, 'message'=> $e->getMessage()];
        }
    }
public function store ( Request $ request ) { try { if ( ! $ request -> input ( 'central_name' ) ) throw new Exception ( " Central name is required! " ) ; $ centralOffice = new CentralOffice ( ) ; $ centralOffice -> central_name = $ request -> input ( 'central_name' ) ; $ centralOffice -> central_details = $ request -> input ( 'central_details' ) ; if ( ! $ centralOffice -> save ( ) ) throw new Exception ( " Critical error when save central office data! " ) ; $ where = [ 'central_office_id' => $ centralOffice -> id , 'role' => 1 ] ; $ centralOffice -> head = TermRelation :: findMyAdmin ( $ where ) ; return [ 'success' => true , 'message' => 'Cetnral office save success' , 'data' => $ centralOffice ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
Save central office or head of district
Save central office or head of district