Пример #1
0
 /**
  * Can the user view tha task?
  * @param User $user
  * @param Task $task
  * @return bool
  */
 public function viewTask(User $user, Task $task)
 {
     if ($task->user_id = $user->id) {
         return true;
     }
     return $task->whereHas('users', function ($q) use($user) {
         $q->where('user_id', $user->id);
     })->count() > 0;
 }
 /**
  * @param Task $task
  * @return array
  */
 public function transform(Task $task)
 {
     return ['id' => (int) $task->id, 'uuid' => $task->uuid, 'name' => $task->name, 'description' => $task->description, 'due_date' => ['unix' => !empty($task->due_date) ? $task->due_date->format('U') : null, 'formatted' => !empty($task->due_date) ? $task->due_date->format('m/d/Y') : null], 'priority' => ['weigth' => $task->priority, 'formatted' => $task->getPriorityText()], 'closed' => (bool) $task->closed, 'created' => ['unix' => $task->created_at->format('U'), 'formatted' => $task->created_at->format('m/d/Y h:i A')], 'updated' => ['unix' => $task->updated_at->format('U'), 'formatted' => $task->updated_at->format('m/d/Y h:i A')], 'links' => ['self' => route('boards.{board}.tasks.show', [$task->board->uuid, $task->uuid])]];
 }
 /**
  * @param $taskId
  */
 public function show(Task $model, $boardId, $taskId)
 {
     $task = $model->with(['user', 'step', 'users'])->ByUuid($taskId)->firstOrFail();
     $this->authorize('viewTask', $task);
     return view('tasks::tasks.show')->with('task', $task);
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->commands([\Modules\Tasks\Console\CreatePermissions::class, \Modules\Tasks\Console\GenerateTasksEntities::class]);
     Board::observe(new UuidObserver());
     Task::observe(new UuidObserver());
 }