-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/project review #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7a8dd3a
3995a07
8acc4cf
e31230b
b4e445e
22d73a0
df9fcd7
9e06a36
eeb1191
6af3907
7cee2b5
8a27630
99f924a
b6ec83e
af656fc
e4726aa
9b15e15
3bd8eb1
4e829bf
0a952a2
9e30af7
b6d9849
654f68e
018d4ba
a3b0398
5104337
4b7ed1b
2aef72a
d6ea72d
7518dd5
14b0eec
73e62fb
54ec927
aafde50
11b6f14
972032a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| namespace App\Actions\Auth; | ||
|
|
||
| use Asciisd\ZohoV8\Models\ZohoLead; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class CreateZohoLeadAction | ||
| { | ||
| /** | ||
| * Create a Zoho lead | ||
| */ | ||
| public function execute(array $data): mixed | ||
| { | ||
| try { | ||
| return ZohoLead::create([ | ||
| 'First_Name' => $data['first_name'], | ||
| 'Last_Name' => $data['last_name'], | ||
| 'Email' => $data['email'], | ||
| 'Phone' => $data['phone'], | ||
| 'Lead_Source' => $data['lead_source'], | ||
| ]); | ||
| } catch (\Throwable $e) { | ||
| Log::channel('zoho_sync')->error('ZohoLead creation failed', [ | ||
| 'email' => $data['email'] ?? null, | ||
| 'error' => $e->getMessage(), | ||
| ]); | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <?php | ||
|
|
||
| namespace App\Actions\Books; | ||
|
|
||
| use App\Models\Book; | ||
| use Illuminate\Support\Facades\Storage; | ||
| use Illuminate\Support\Facades\Log; | ||
|
|
||
| class GenerateBookDownloadUrl | ||
| { | ||
| /** | ||
| * Generate a temporary download URL for a book | ||
| */ | ||
| public function execute(Book $book, int $minutesValid = 30): ?string | ||
| { | ||
| try { | ||
| // Check if file_src exists | ||
| if (!$book->file_src) { | ||
| Log::warning('Book file_src is empty', ['book_id' => $book->id]); | ||
| return null; | ||
| } | ||
|
|
||
| $path = $this->extractPath($book->file_src); | ||
|
|
||
| if (!$path) { | ||
| Log::warning('Could not extract path from file_src', [ | ||
| 'book_id' => $book->id, | ||
| 'file_src' => $book->file_src | ||
| ]); | ||
| return null; | ||
| } | ||
|
|
||
| return Storage::disk('s3_public')->temporaryUrl( | ||
| $path, | ||
| now()->addMinutes($minutesValid) | ||
| ); | ||
|
|
||
| } catch (\Exception $e) { | ||
| Log::error('Failed to generate book download URL', [ | ||
| 'book_id' => $book->id, | ||
| 'error' => $e->getMessage() | ||
| ]); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Extract path from file_src (supports both JSON and plain string) | ||
| */ | ||
| private function extractPath(string $fileSrc): ?string | ||
| { | ||
| // Try to decode as JSON first | ||
| $decoded = json_decode($fileSrc); | ||
|
|
||
| if (json_last_error() === JSON_ERROR_NONE && is_object($decoded) && isset($decoded->path)) { | ||
| return $decoded->path; | ||
| } | ||
|
|
||
| // If not JSON, treat as plain path | ||
| return trim($fileSrc) ?: null; | ||
| } | ||
| } |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still deleted