Added handler

This commit is contained in:
Gregorio Chiko Putra 2017-09-06 14:49:14 +07:00
parent bb834494bd
commit 992874ce1c

View File

@ -7,7 +7,6 @@ use App\Models\Access;
use \Core\Token; use \Core\Token;
use \Core\Session; use \Core\Session;
use \Core\Redirect; use \Core\Redirect;
use \Core\Validate;
class Posts class Posts
{ {
@ -70,8 +69,6 @@ class Posts
'posts' => $posts, 'posts' => $posts,
'status' => $status 'status' => $status
]); ]);
return true;
} }
public function entry() public function entry()
@ -86,8 +83,6 @@ class Posts
'user' => $user, 'user' => $user,
'token' => Token::generate() 'token' => Token::generate()
]); ]);
return true;
} else { } else {
Redirect::to('/'); Redirect::to('/');
} }
@ -159,7 +154,8 @@ class Posts
foreach ($args as $value) { foreach ($args as $value) {
if ($value == '') { if ($value == '') {
Session::flash('info', 'All data must not be empty'); Session::flash('info', 'All data must not be empty');
Redirect::to('./entry'); Redirect::to('/');
die();
} }
} }
@ -186,6 +182,9 @@ class Posts
if ($this->post->update($table, $args, $id)) { if ($this->post->update($table, $args, $id)) {
Session::flash('info', 'Data successfuly updated'); Session::flash('info', 'Data successfuly updated');
Redirect::to('/'); Redirect::to('/');
} else {
Session::flash('info', 'Data must not be same');
Redirect::to("./$id");
} }
} }