Skip to content

Commit

Permalink
Final
Browse files Browse the repository at this point in the history
  • Loading branch information
luistrejohi committed Sep 30, 2018
1 parent 9801c35 commit 3fac5af
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/Http/Controllers/Pay_moduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ public function update(Request $request, $id)
//$pay_module->ruta=$request->ruta;
//$pay_module->save();
//
$ruta=Input::get('ruta');
$latitud=Input::get('latitud');
$longitud=Input::get('longitud');
$pay_module= pay_module::find($id);
$pay_module->ruta=$ruta;
$pay_module->latitud=$latitud;
$pay_module->longitud=$longitud;
$pay_module->save();

//Pay_module::where('id', $id)->update($request->all());
return response()->json(['ok'=>'update','$pay_module'=>$ruta], 200);
return response()->json(['ok'=>$longitud,'$pay_module'=>$latitud], 200);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/PulseraController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public function create()
public function store(Request $request)
{
//
$pulsera = new pulsera;
$pulsera->serial_number = $request->serial_number;
$pulsera->creado = new\DateTime();
$pulsera->save();
}

/**
Expand Down
31 changes: 30 additions & 1 deletion app/Http/Controllers/Pulsera_userController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Pulseras_user;
use App\User;
use Illuminate\Http\Request;

class Pulsera_userController extends Controller
Expand Down Expand Up @@ -36,6 +37,12 @@ public function create()
public function store(Request $request)
{
//
$pulseras_user = new pulseras_user;
$pulseras_user->pulsera_id = $request->pulsera_id;
$pulseras_user->owner_id = $request->owner_id;
$pulseras_user->permited_user = $request->permited_user;
$pulseras_user->save();
return response()->json(['Prueba'=>$pulseras_user], 200);
}

/**
Expand All @@ -44,9 +51,31 @@ public function store(Request $request)
* @param \App\Pulseras_user $pulseras_user
* @return \Illuminate\Http\Response
*/
public function show(Pulseras_user $pulseras_user)
public function show($permited_user)
{
//
$idDuenios = pulseras_user::where('permited_user',$permited_user)->get();
$aux=0;
$valueAux;
$valueAuxNombre;
foreach ($idDuenios as $value) {
if($value['parent'] == 0){
$valueAux[$aux]= $value['owner_id'];
}
$aux+=1;
}

$aux=0;

foreach ($valueAux as $value) {
$valueAuxNombre[$aux]= user::find($valueAux[$aux])->name;

$JsonString[$valueAuxNombre[$aux]]=$valueAux[$aux];
$aux+=1;
}
$jsonSt = json_encode($JsonString);
//$owners_id =
return response()->json([$JsonString], 200);
}

/**
Expand Down
24 changes: 22 additions & 2 deletions app/Http/Controllers/User_transport_ubicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\User_transport_ubication;
use App\Pay_module;
use Illuminate\Http\Request;

class User_transport_ubicationController extends Controller
Expand Down Expand Up @@ -50,9 +51,20 @@ public function store(Request $request)
* @param \App\User_transport_ubication $user_transport_ubication
* @return \Illuminate\Http\Response
*/
public function show(User_transport_ubication $user_transport_ubication)
public function show($user_id)
{
//
$id_pay_module = User_transport_ubication::where('user_id',$user_id)->first();
$id_pay_module = $id_pay_module->module_id;
$pay_module = Pay_module::find($id_pay_module);
$ruta = $pay_module->ruta;
$latitud = $pay_module->latitud;
$longitud = $pay_module->longitud;
return response()->json(['id_module'=>$id_pay_module,
'ruta'=>$ruta,
'longitud'=>$longitud,
'latitud'=>$latitud], 200);

}

/**
Expand Down Expand Up @@ -84,8 +96,16 @@ public function update(Request $request, User_transport_ubication $user_transpor
* @param \App\User_transport_ubication $user_transport_ubication
* @return \Illuminate\Http\Response
*/
public function destroy(User_transport_ubication $user_transport_ubication)
public function destroy( $user_id)
{
//
$user_transport_ubication = User_transport_ubication::where('user_id',$user_id)->delete();
//$id = $user_transport_ubication->id;
//return response()->json(['Prueba'=>$id], 200);

//$user_transport_ubicationFinal= User_transport_ubication::find(2);

//$user_transport_ubicationFinal->delete();

}
}
3 changes: 3 additions & 0 deletions app/User_transport_ubication.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
class User_transport_ubication extends Model
{
//
public function pay_module(){
return $this->belongsTo(App\Pay_module);
}
}

0 comments on commit 3fac5af

Please sign in to comment.