Created
February 10, 2018 07:51
-
-
Save kresnasatya/b493f8f5a9b65f67607f481d52825d86 to your computer and use it in GitHub Desktop.
Trigger php dan JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Controller */ | |
class Foo extends Controller { | |
public function removeRequest() { | |
print_r($_POST); // atau $_GET tergantung method yang kamu pakai untuk memicu script tadi | |
// tujuannya membatalkan perintah berikutnya dan melihat hasil keluaran dari $_POST tadi. | |
exit(); | |
$this->Your_model->permintaan2Delete($_POST); | |
} | |
} | |
/* Model */ | |
class Your_mode extends Model { | |
public function permintaan2Delete($data) { | |
// run your query here | |
} | |
} | |
/* | |
Routing | |
*/ | |
// CI | |
$route['something-or-directory-whatever/remove_request'] = 'something-or-directory-whatever/Foo/removeRequest'; | |
// Laravel | |
Route::post('something-or-directory-whatever/remove_request', 'something-or-directory-whatever\Foo@removeRequest')->name(foo.remove); | |
/* View */ | |
<script> | |
if (confirm('Confirm to delete')) { | |
// run your route here | |
// CI: <?php echo site_url('something-or-directory-whatever/remove_request'); ?> | |
// Laravel: {{ route('foo.remove', $post) }} | |
} | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment