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\Controllers\Controller;
use App\Http\Resources\FileResource; use App\Http\Resources\FileResource;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Exceptions\HttpResponseException;
class TaskFileController extends Controller class TaskFileController extends Controller
{ {
@ -41,7 +40,7 @@ class TaskFileController extends Controller
// guest or de active // guest or de active
// return files as file resource // return files as file resource
[$business, $project, $task] = $this->checkBelonging($business, $project, $task); [$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) 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 // return the file resource or stream it
[$business, $project, $task] = $this->checkBelonging($business, $project, $task); [$business, $project, $task] = $this->checkBelonging($business, $project, $task);
$file = File::find($file);
$file = File::findOrFail($file);
if ($file->user_id !== Auth::id()) { if ($file->user_id !== Auth::id()) {
abort(Response::HTTP_UNAUTHORIZED); abort(Response::HTTP_UNAUTHORIZED);
} }

Loading…
Cancel
Save