public function destroy($id)
 {
     if (Auth::user()->is_admin) {
         $count = 0;
         $business = BusinessType::find($id);
         $clients = Client::select('business_type_id')->get();
         foreach ($clients as $key => $client) {
             $u = $client->business_type_id;
             $uarray = explode(',', $u);
             if (in_array($id, $uarray, true)) {
                 $count = $count + 1;
             }
         }
         if ($count > 0) {
             $field = $count == 1 ? ' ' : 's';
             $field2 = $count == 1 ? ' pertenece' : ' pertenecen';
             $message = $count . " Cliente" . $field . $field2 . " al Tipo de Negocio  " . $business->name;
             Session::flash('error', $message);
             return Redirect::to('negocios/' . $id);
         } else {
             $business->delete();
             $message = "Tipo de Negocio Eliminado con éxito";
             Session::flash('message', $message);
             return Redirect::to('negocios');
         }
     }
 }
Example #2
0
 public function destroy($id)
 {
     if (Auth::user()->is_admin) {
         $count = 0;
         $zone = Zone::find($id);
         $clients = Client::select('zone_id')->get();
         foreach ($clients as $key => $client) {
             $u = $client->zone_id;
             $uarray = explode(',', $u);
             if (in_array($id, $uarray, true)) {
                 $count = $count + 1;
             }
         }
         if ($count > 0) {
             $field = $count == 1 ? ' ' : 's';
             $field2 = $count == 1 ? ' pertenece' : ' pertenecen';
             $message = $count . " Cliente" . $field . $field2 . " a la zona " . $zone->name;
             Session::flash('error', $message);
             return Redirect::to('zonas/' . $id);
         } else {
             $zone->delete();
             $message = "Zona Eliminada con éxito";
             Session::flash('message', $message);
             return Redirect::to('zonas');
         }
     }
 }
Example #3
0
 /**
  * @covers Client::select()
  * @test
  */
 public function testSelect()
 {
     $stub = $this->getMockBuilder('Sugar\\Solr\\Request\\Factory')->disableOriginalConstructor()->getMock();
     $stub->expects($this->once())->method('request')->will($this->returnValue('{}'));
     $obj = new Client('localhost', 'core', 8983);
     $obj->setFactory($stub);
     $this->assertEquals([], $obj->select([]));
 }
 /**
  * Show a list of all the blog posts formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $clients = Client::select(array('oauth_clients.id', 'oauth_clients.name', 'oauth_clients.created_at'));
     return Datatables::of($clients)->add_column('actions', '<a href="{{{ URL::to(\'admin/clients/\' . $id . \'/edit\' ) }}}" class="btn btn-default btn-xs iframe" >{{{ Lang::get(\'button.edit\') }}}</a>
             <a href="{{{ URL::to(\'admin/clients/\' . $id . \'/delete\' ) }}}" class="btn btn-xs btn-danger iframe">{{{ Lang::get(\'button.delete\') }}}</a>
         ')->remove_column('id')->make();
 }