Last active
July 8, 2023 03:55
-
-
Save cyberfly/c0e050a28f42de82dc2db0cb3a4792e7 to your computer and use it in GitHub Desktop.
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
<!--list errors, formatted--> | |
<?= validation_list_errors() ?> | |
<!--errors array--> | |
<?php $errors = validation_errors(); var_dump($errors); ?> | |
<!--check if errors not empty, and list it--> | |
<?php if (!empty(validation_errors())) : ?> | |
<div class="alert alert-danger" role="alert"> | |
<?= validation_list_errors() ?> | |
</div> | |
<?php endif ?> | |
<!--show single error--> | |
<?= validation_show_error('description') ?> | |
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
public function store() | |
{ | |
$rules = [ | |
'title' => 'required', | |
'description' => 'required', | |
]; | |
if (! $this->validate($rules)) { | |
return redirect()->back()->withInput(); | |
} | |
$data = [ | |
'title' => $this->request->getPost('title'), | |
'description' => $this->request->getPost('description'), | |
]; | |
$department_model = new Department(); | |
$department = $department_model->insert($data); | |
session()->setFlashdata('success', 'Department created'); | |
return redirect()->to('/departments'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment