app/Http/Controllers/Admin/VendorsController.php
// ACTIVATE OR DEACTIVATE VENDOR WITH AN ID
ACTIVATE OR DEACTIVATE VENDOR WITH AN ID
ACTIVATE OR DEACTIVATE VENDOR WITH AN ID
public function changeStatus($vendID)
    {
        try {
            $vend = Vendor::find($vendID);
            if (!$vend) {
                return redirect()->route('admin.vendors')->with([
                    'error' => 'No such vendor'
                ]);
            }
            $vendStat = ($vend->status == 1)? 0: 1;
            $vend->update([
                'status' => $vendStat
            ]);
            return redirect()->route('admin.vendors')->with([
                'success' => 'Status changed successfully'
            ]);
        } catch (\Throwable $th) {
            return redirect()->route('admin.vendors')->with([
                'error' => 'Something went terribly wrong'
            ]);
        }
    }
public function changeStatus ( $ vendID ) { try { $ vend = Vendor :: find ( $ vendID ) ; if ( ! $ vend ) { return redirect ( ) -> route ( 'admin.vendors' ) -> with ( [ 'error' => 'No such vendor' ] ) ; } $ vendStat = ( $ vend -> status == 1 ) ? 0 : 1 ; $ vend -> update ( [ 'status' => $ vendStat ] ) ; return redirect ( ) -> route ( 'admin.vendors' ) -> with ( [ 'success' => 'Status changed successfully' ] ) ; } catch ( \ Throwable $ th ) { return redirect ( ) -> route ( 'admin.vendors' ) -> with ( [ 'error' => 'Something went terribly wrong' ] ) ; } }
ACTIVATE OR DEACTIVATE VENDOR WITH AN ID
ACTIVATE OR DEACTIVATE VENDOR WITH AN ID
// DATABASE VENDOR OF AN ID // DATABASE VENDOR EXISTANCE CHECK // REDIRECT TO VAENDORS TABLE WITH ERROR MESSAGE // CHANGE VENDOR'S STATUS // DATABASE UPDATE VENDOR'S STATUS STATEMENT // REDIRECT TO VENDORS TABLE WITH SUCCESS MESSAGE // REDIRECT TO VENDORS TABLE WITH ERROR MESSAGE