$email = $request->input('email'); $usuario = Usuario::where('nombre', $nombre)->first(); if ($usuario) { $mascotas = Mascota::where('id_usuario', $usuario->id)->get(); return response()->json(['msgStatus' => 'OK', 'msgError' => '', 'usuario' => $usuario, 'mascotas' => $mascotas]); } else { $registroUsuario = Usuario::create(array('nombre' => $nombre, 'appellidop' => $apellidop, 'apellidom' => $apellidom, 'email' => $email)); if ($registroUsuario) { return response()->json(['msgStatus' => 'ERROR', 'msgError' => 'ERROR', 'usuario' => $registroUsuario]); } } }); Route::get('usuarios', function (Request $request) { return Usuario::all(); }); Route::get('mascotas', function (Request $request) { // return Mascota::find(13)->has('usuario')->get(); $usuario = Usuario::find(1)->with('mascotas')->get(); session()->put('usuario', $usuario); return session()->get('usuario'); }); Route::get('mascotas', function (Request $request) { return Mascota::all(); }); Route::get('mascotas/{id}', function ($id) { $mascotas = Mascota::where('id_usuario', $id)->first(); return $mascotas->nombre; }); // Route::get('ejemplo', function () { // return View('ejemplo'); // });
public function presentarse() { return parent::presentarse() . "gato"; }
public function presentarse() { return parent::presentarse() . "reptil"; }