diff --git a/app/Http/Controllers/TaskFileController.php b/app/Http/Controllers/TaskFileController.php index 6750715..b8bd77c 100644 --- a/app/Http/Controllers/TaskFileController.php +++ b/app/Http/Controllers/TaskFileController.php @@ -11,7 +11,6 @@ use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Http\Resources\FileResource; use Symfony\Component\HttpFoundation\Response; -use Illuminate\Http\Exceptions\HttpResponseException; class TaskFileController extends Controller { @@ -41,7 +40,7 @@ class TaskFileController extends Controller // guest or de active // return files as file resource [$business, $project, $task] = $this->checkBelonging($business, $project, $task); - return FileResource::collection($task->files); + return FileResource::collection($task->files ?? []); } public function sync(Request $request,int $business, int $project, int $task) @@ -78,7 +77,7 @@ class TaskFileController extends Controller // return the file resource or stream it [$business, $project, $task] = $this->checkBelonging($business, $project, $task); - $file = File::find($file); + $file = File::findOrFail($file); if ($file->user_id !== Auth::id()) { abort(Response::HTTP_UNAUTHORIZED); }