-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
ContactPhotoController.php
49 lines (41 loc) · 1.67 KB
/
ContactPhotoController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace App\Contact\ManagePhotos\Web\Controllers;
use App\Contact\ManagePhotos\Web\ViewHelpers\ContactPhotosIndexViewHelper;
use App\Contact\ManagePhotos\Web\ViewHelpers\ContactPhotosShowViewHelper;
use App\Helpers\PaginatorHelper;
use App\Http\Controllers\Controller;
use App\Models\Contact;
use App\Models\File;
use App\Models\Vault;
use App\Vault\ManageVault\Web\ViewHelpers\VaultIndexViewHelper;
use Illuminate\Http\Request;
use Inertia\Inertia;
class ContactPhotoController extends Controller
{
public function index(Request $request, int $vaultId, int $contactId)
{
$vault = Vault::findOrFail($vaultId);
$contact = Contact::findOrFail($contactId);
$files = File::where('contact_id', $contactId)
->where('type', File::TYPE_PHOTO)
->orderBy('created_at', 'desc')
->paginate(30);
return Inertia::render('Vault/Contact/Photos/Index', [
'layoutData' => VaultIndexViewHelper::layoutData($vault),
'data' => ContactPhotosIndexViewHelper::data($files, $contact),
'paginator' => PaginatorHelper::getData($files),
]);
}
public function show(Request $request, int $vaultId, int $contactId, int $photoId)
{
$vault = Vault::findOrFail($vaultId);
$contact = Contact::findOrFail($contactId);
$photo = File::where('contact_id', $contactId)
->where('type', File::TYPE_PHOTO)
->findOrFail($photoId);
return Inertia::render('Vault/Contact/Photos/Show', [
'layoutData' => VaultIndexViewHelper::layoutData($vault),
'data' => ContactPhotosShowViewHelper::data($photo, $contact),
]);
}
}