Image now a file
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Api\User;
|
||||
|
||||
use Exception;
|
||||
use Khofmann\Models\User\User as MUser;
|
||||
use Khofmann\Input\Input;
|
||||
|
||||
class User
|
||||
{
|
||||
public function get($id)
|
||||
{
|
||||
try {
|
||||
return json_encode(MUser::getByID($id));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "NotFound":
|
||||
throw new Exception("User not Found", 404);
|
||||
default:
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function post($id)
|
||||
{
|
||||
$username = Input::post("username");
|
||||
$password = Input::post("password");
|
||||
$image = Input::file("image");
|
||||
|
||||
try {
|
||||
return json_encode(MUser::getByID($id)->update($username, $password, $image));
|
||||
} catch (Exception $err) {
|
||||
switch ($err->getMessage()) {
|
||||
case "NotFound":
|
||||
throw new Exception("User not Found", 404);
|
||||
case "FailedUsername":
|
||||
throw new Exception("Failed to update username", 500);
|
||||
case "FailedPassword":
|
||||
throw new Exception("Failed to update password", 500);
|
||||
case "FailedImage":
|
||||
throw new Exception("Failed to update image", 500);
|
||||
default:
|
||||
throw $err;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user