Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pisane na szybko, po 4 piwkach z głowy. Wersja ogólnie uproszczona.
- Klasa kontrolera, powiedzmy user, a w niej funkcja do edycji maila.
- public function editEmail() {
- try{
- // wywołuje model o tej samej funkcji
- $this->model->editEmail($_POST['email']);
- // zwraca status
- $status = ["status"=>true, "message"=>"Nie ma lipy :)"];
- } catch(\Exception $e) {
- $status = ["status"=>false, "message"=>$e->getMessage()];
- }
- echo json_encode($status);
- }
- Tutaj model, tutaj robię walidację. W klasie "User" już tego nie sprawdzam
- public function editEmail(string $email) : bool {
- $val = new \Utils\Validiator();
- $val->pattern("email", $email);
- // sprawdzam czy success
- if($val->isSuccess() === false) {
- throw new \Exception("Lipa :(");
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement