app/Http/Controllers/ContactController.php
/**
     * Checks if the given contact id already exist for the current business.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Checks if the given contact id already exist for the current business.
Checks if the given contact id already exist for the current business .
public function checkContactId(Request $request)
    {
        $contact_id = $request->input('contact_id');
        $valid = 'true';
        if (!empty($contact_id)) {
            $business_id = $request->session()->get('user.business_id');
            $hidden_id = $request->input('hidden_id');
            $query = Contact::where('business_id', $business_id)
                            ->where('contact_id', $contact_id);
            if (!empty($hidden_id)) {
                $query->where('id', '!=', $hidden_id);
            }
            $count = $query->count();
            if ($count > 0) {
                $valid = 'false';
            }
        }
        echo $valid;
        exit;
    }
public function checkContactId ( Request $ request ) { $ contact_id = $ request -> input ( 'contact_id' ) ; $ valid = 'true' ; if ( ! empty ( $ contact_id ) ) { $ business_id = $ request -> session ( ) -> get ( 'user.business_id' ) ; $ hidden_id = $ request -> input ( 'hidden_id' ) ; $ query = Contact :: where ( 'business_id' , $ business_id ) -> where ( 'contact_id' , $ contact_id ) ; if ( ! empty ( $ hidden_id ) ) { $ query -> where ( 'id' , '!=' , $ hidden_id ) ; } $ count = $ query -> count ( ) ; if ( $ count > 0 ) { $ valid = 'false' ; } } echo $ valid ; exit ; }
Checks if the given contact id already exist for the current business.
Checks if the given contact id already exist for the current business .