コード例 #1
0
 public function registry(Request $request, $registry = null)
 {
     // [ NO SE SELECCIONA NINGÚN REGISTRO ]
     if (empty($registry)) {
         // obtiene un registro al azar
         $registry = Trusts::all()->lists('registry')->random();
         // obtiene todos los fideicomisos con el mismo registro
         $response = Trusts::where('registry', $registry)->select($this->registry_fields)->get();
         // los regresa en JSONxCORS
         return response()->json($response)->header('Access-Control-Allow-Origin', '*');
     } else {
         // separa los registros
         $list = explode('|', $registry);
         // obtiene todos los fideicomisos con el mismo registro
         $response = Trusts::whereIn('registry', $list)->select($this->registry_fields)->get();
         // los regresa en JSONxCORS
         return response()->json($response)->header('Access-Control-Allow-Origin', '*');
     }
 }