Implemented the authenticated admin contact system.
This commit is contained in:
23
app/Http/Controllers/SupportAttachmentController.php
Normal file
23
app/Http/Controllers/SupportAttachmentController.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\SupportAttachment;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class SupportAttachmentController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, SupportAttachment $attachment): StreamedResponse
|
||||
{
|
||||
$attachment->loadMissing('message.conversation');
|
||||
|
||||
abort_unless(
|
||||
$request->user()?->is_admin || $attachment->message->conversation->user_id === $request->user()?->id,
|
||||
403,
|
||||
);
|
||||
|
||||
return Storage::disk($attachment->disk)->download($attachment->path, $attachment->original_name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user