Browse Source

Fix task file

pull/2/head
Mohammad Akbari 4 years ago
parent
commit
2c0e162bf4
Signed by: akbarjimi GPG Key ID: 55726AEFECE5E683
  1. 5
      app/Http/Controllers/TaskFileController.php

5
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);
}

Loading…
Cancel
Save