brennersousa /
cafeapi
| 1 | <?php |
||
| 2 | require __DIR__ . "/assets/config.php"; |
||
| 3 | require __DIR__ . "/../vendor/autoload.php"; |
||
| 4 | |||
| 5 | use BrennerSousa\CafeApi\Me; |
||
| 6 | |||
| 7 | $me = new Me( |
||
| 8 | "localhost/cursos/fullstackphp-api/cafeapi/", |
||
| 9 | "[email protected]", |
||
| 10 | "12345678" |
||
| 11 | ); |
||
| 12 | |||
| 13 | /** |
||
| 14 | * me |
||
| 15 | */ |
||
| 16 | echo "<h1>ME</h1>"; |
||
| 17 | |||
| 18 | $user = $me->me(); |
||
| 19 | var_dump($user->response()); |
||
| 20 | |||
| 21 | /** |
||
| 22 | * update |
||
| 23 | */ |
||
| 24 | echo "<h1>UPDATE</h1>"; |
||
| 25 | |||
| 26 | $update = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRIPPED); |
||
| 27 | |||
| 28 | if ($update && !empty($update["user"])) { |
||
| 29 | $user->update($update); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 30 | |||
| 31 | if ($user->error()) { |
||
| 32 | echo "<p class='error'>{$user->error()->message}</p>"; |
||
| 33 | } else { |
||
| 34 | var_dump($user->response()->user); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | $userData = $user->me()->response()->user; |
||
| 39 | ?> |
||
| 40 | <form action="" method="post"> |
||
| 41 | <input type="hidden" name="user" value="true"/> |
||
| 42 | <input type="text" name="first_name" value="<?= ($userData->first_name ?? null); ?>"/> |
||
| 43 | <input type="text" name="last_name" value="<?= ($userData->last_name ?? null); ?>"/> |
||
| 44 | <input type="text" name="genre" value="<?= ($userData->genre ?? null); ?>"/> |
||
| 45 | <input type="text" name="datebirth" value="<?= ($userData->datebirth ?? null); ?>"/> |
||
| 46 | <input type="text" name="document" value="<?= ($userData->document ?? null); ?>"/> |
||
| 47 | <button>Atualizar</button> |
||
| 48 | </form> |
||
| 49 | <?php |
||
| 50 | |||
| 51 | /** |
||
| 52 | * PHOTO |
||
| 53 | */ |
||
| 54 | echo "<h1>PHOTO</h1>"; |
||
| 55 | |||
| 56 | $photo = ($_FILES["photo"] ?? null); |
||
| 57 | |||
| 58 | if ($photo) { |
||
| 59 | $user->photo($photo); |
||
| 60 | |||
| 61 | if ($user->error()) { |
||
| 62 | echo "<p class='error'>{$user->error()->message}</p>"; |
||
| 63 | } else { |
||
| 64 | var_dump($user->me()->response()->user->photo); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | ?> |
||
| 68 | <form action="" method="post" enctype="multipart/form-data"> |
||
| 69 | <input type="file" name="photo"/> |
||
| 70 | <button>Atualizar</button> |
||
| 71 | </form> |
||
| 72 | <?php |
||
| 73 | |||
| 74 |