-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: address on dashboard feed (monicahq/chandler#206)
- Loading branch information
Showing
22 changed files
with
482 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ns/Contact/ManageContactAddresses/Web/Controllers/ContactModuleAddressImageController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Contact\ManageContactAddresses\Web\Controllers; | ||
|
||
use App\Helpers\MapHelper; | ||
use App\Http\Controllers\Controller; | ||
use App\Models\Address; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Facades\Http; | ||
use Illuminate\Support\Facades\Response; | ||
|
||
class ContactModuleAddressImageController extends Controller | ||
{ | ||
public function show(Request $request, int $vaultId, int $contactId, int $addressId, int $width, int $height) | ||
{ | ||
$address = Address::where('contact_id', $contactId) | ||
->findOrFail($addressId); | ||
|
||
$url = MapHelper::getStaticImage($address, $width, $height); | ||
|
||
$response = Http::get($url) | ||
->throw(); | ||
|
||
return Response::stream(function () use ($response) { | ||
echo $response->body(); | ||
}, | ||
200, | ||
Arr::only($response->headers(), [ | ||
'Content-Length', | ||
'Content-Type', | ||
'Cache-Control', | ||
'Date', | ||
'ETag', | ||
]) | ||
); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
domains/Contact/ManageContactFeed/Web/ViewHelpers/Actions/ActionFeedAddress.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\Contact\ManageContactFeed\Web\ViewHelpers\Actions; | ||
|
||
use App\Helpers\MapHelper; | ||
use App\Models\ContactFeedItem; | ||
use App\Models\User; | ||
|
||
class ActionFeedAddress | ||
{ | ||
public static function data(ContactFeedItem $item, User $user): array | ||
{ | ||
$contact = $item->contact; | ||
$address = $item->feedable; | ||
|
||
return [ | ||
'address' => [ | ||
'object' => $address ? [ | ||
'id' => $address->id, | ||
'street' => $address->street, | ||
'city' => $address->city, | ||
'province' => $address->province, | ||
'postal_code' => $address->postal_code, | ||
'country' => $address->country, | ||
'type' => $address->addressType ? [ | ||
'id' => $address->addressType->id, | ||
'name' => $address->addressType->name, | ||
] : null, | ||
'image' => route('contact.address.image.show', [ | ||
'vault' => $contact->vault_id, | ||
'contact' => $contact->id, | ||
'address' => $address->id, | ||
'width' => 300, | ||
'height' => 100, | ||
]), | ||
'url' => [ | ||
'show' => MapHelper::getMapLink($address, $user), | ||
], | ||
] : null, | ||
'description' => $item->description, | ||
], | ||
'contact' => [ | ||
'id' => $contact->id, | ||
'name' => $contact->name, | ||
'age' => $contact->age, | ||
'avatar' => $contact->avatar, | ||
'url' => route('contact.show', [ | ||
'vault' => $contact->vault_id, | ||
'contact' => $contact->id, | ||
]), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.