-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ability to create tasks that are not linked to contacts (#2067
- Loading branch information
Showing
57 changed files
with
1,529 additions
and
1,149 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
UNRELEASED CHANGES: | ||
|
||
* | ||
* Add ability to create tasks that are not linked to any contacts | ||
|
||
RELEASED VERSIONS: | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Contact\Task; | ||
use Illuminate\Http\Request; | ||
use App\Models\Contact\Contact; | ||
use App\Services\Task\CreateTask; | ||
use App\Services\Task\UpdateTask; | ||
use App\Services\Task\DestroyTask; | ||
use App\Http\Resources\Task\Task as TaskResource; | ||
|
||
class TasksController extends Controller | ||
{ | ||
/** | ||
* Get the list of tasks for the account. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return TaskResource::collection(auth()->user()->account->tasks); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param $request | ||
* @param Contact $contact | ||
* @return Task | ||
*/ | ||
public function store(Request $request) : Task | ||
{ | ||
return (new CreateTask)->execute([ | ||
'account_id' => auth()->user()->account->id, | ||
'contact_id' => ($request->get('contact_id') == '' ? null : $request->get('contact_id')), | ||
'title' => $request->get('title'), | ||
'description' => ($request->get('description') == '' ? null : $request->get('description')), | ||
]); | ||
} | ||
|
||
/** | ||
* Update a task. | ||
* | ||
* @param Request $request | ||
* @return Task | ||
*/ | ||
public function update(Request $request, $taskId) : Task | ||
{ | ||
return (new UpdateTask)->execute([ | ||
'account_id' => auth()->user()->account->id, | ||
'task_id' => $taskId, | ||
'contact_id' => ($request->get('contact_id') == '' ? null : $request->get('contact_id')), | ||
'title' => $request->get('title'), | ||
'description' => ($request->get('description') == '' ? null : $request->get('description')), | ||
'completed' => $request->get('completed'), | ||
]); | ||
} | ||
|
||
/** | ||
* Destroy the task. | ||
* | ||
* @param Contact $contact | ||
* @param Task $task | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy(Contact $contact, $taskId) | ||
{ | ||
(new DestroyTask)->execute([ | ||
'task_id' => $taskId, | ||
'account_id' => auth()->user()->account->id, | ||
]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.