...
This commit is contained in:
parent
a9e7afd13a
commit
ba3de1ae99
31 changed files with 329 additions and 5 deletions
|
|
@ -0,0 +1,46 @@
|
|||
https://www.youtube.com/watch?v=104Q76g7DWA&list=PLT9miexWCpPW6Z_OXNv2d78cqCrZaPrVG&index=36
|
||||
|
||||
ProjectController
|
||||
```php
|
||||
// Post
|
||||
public function addProject()
|
||||
{
|
||||
$rules = [
|
||||
"name" => "required",
|
||||
"budget" => "required"
|
||||
];
|
||||
|
||||
if(!$this->validate($rules)) {
|
||||
$response = [
|
||||
"status" => false,
|
||||
"message" => $this->validator->getErrors(),
|
||||
"data" => []
|
||||
];
|
||||
}else {
|
||||
$user_id = auth()-id();
|
||||
$name = $this->request->getVar("name");
|
||||
$budget = $this->request->getVar("budget");
|
||||
$pm = new ProjectModel();
|
||||
$data= [
|
||||
"user_id" => $user_id,
|
||||
"name" => name,
|
||||
"budget" => budget
|
||||
];
|
||||
if($pm->insert($data)) {
|
||||
$response = [
|
||||
"status" => true,
|
||||
"message" => "project saved",
|
||||
"data" => []
|
||||
];
|
||||
}else{
|
||||
$response = [
|
||||
"status" => false,
|
||||
"message" => "project save failed",
|
||||
"data" => []
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$return $this->respondCreated($response);
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue