Skip to content

Commit a2e70e1

Browse files
authored
Merge pull request #187 from fleetbase/dev-v1.6.35
v1.6.35 ~ VerificationCode SMS must throw exception always
2 parents 779345c + 0072bdb commit a2e70e1

10 files changed

Lines changed: 484 additions & 11 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fleetbase/core-api",
3-
"version": "1.6.34",
3+
"version": "1.6.35",
44
"description": "Core Framework and Resources for Fleetbase API",
55
"keywords": [
66
"fleetbase",

src/Facades/FileResolver.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Fleetbase\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
/**
8+
* FileResolver Facade.
9+
*
10+
* Provides convenient static-like access to the FileResolverService.
11+
*
12+
* @method static \Fleetbase\Models\File|null resolve($file, ?string $path = 'uploads', ?string $disk = null)
13+
* @method static array resolveMany(array $files, ?string $path = 'uploads', ?string $disk = null)
14+
* @method static bool resolveAndAttach($file, $model, string $attribute, ?string $path = 'uploads', ?string $disk = null)
15+
*
16+
* @see \Fleetbase\Services\FileResolverService
17+
*/
18+
class FileResolver extends Facade
19+
{
20+
/**
21+
* Get the registered name of the component.
22+
*
23+
* @return string
24+
*/
25+
protected static function getFacadeAccessor()
26+
{
27+
return \Fleetbase\Services\FileResolverService::class;
28+
}
29+
}

src/Http/Controllers/Internal/v1/OnboardController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function createAccount(OnboardRequest $request)
5858
]);
5959

6060
// create company FIRST (required for billing resource tracking)
61-
$company = Company::create(['name' => $request->input('organization_name')]);
61+
$company = Company::create(['name' => $request->input('organization_name'), 'onboarding_completed_at' => now()]);
6262

6363
// set company_uuid before creating user (required for billing resource tracking)
6464
$attributes['company_uuid'] = $company->uuid;
@@ -73,7 +73,7 @@ public function createAccount(OnboardRequest $request)
7373
$user->setUserType($isAdmin ? 'admin' : 'user');
7474

7575
// set company owner
76-
$company->setOwner($user)->save();
76+
$company->setOwner($user, true)->save();
7777

7878
// assign user to organization
7979
$user->assignCompany($company, 'Administrator');

src/Models/Company.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,12 @@ public function assignOwner(User $user): User
254254
*
255255
* @return Company
256256
*/
257-
public function setOwner(User $user)
257+
public function setOwner(User $user, bool $completedOnboarding = false)
258258
{
259259
$this->owner_uuid = $user->uuid;
260+
if ($completedOnboarding) {
261+
$this->onboarding_completed_by_uuid = $user->uuid;
262+
}
260263

261264
return $this;
262265
}

src/Models/VerificationCode.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,7 @@ public static function generateSmsVerificationFor($subject, $for = 'phone_verifi
216216
'error' => $e->getMessage(),
217217
]);
218218

219-
// Optionally rethrow based on configuration
220-
if (config('sms.throw_on_error', false)) {
221-
throw $e;
222-
}
219+
throw $e;
223220
}
224221
}
225222

src/Providers/CoreServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public function register()
135135
$this->app->singleton(ReportSchemaRegistry::class, function () {
136136
return new ReportSchemaRegistry();
137137
});
138+
139+
// register file resolver service
140+
$this->app->singleton(\Fleetbase\Services\FileResolverService::class, function ($app) {
141+
return new \Fleetbase\Services\FileResolverService();
142+
});
138143
}
139144

140145
/**

src/Rules/FileInput.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Fleetbase\Rules;
4+
5+
use Fleetbase\Support\Utils;
6+
use Illuminate\Contracts\Validation\Rule;
7+
use Illuminate\Http\UploadedFile;
8+
use Illuminate\Support\Str;
9+
10+
/**
11+
* FileInput Validation Rule.
12+
*
13+
* Validates that input is a valid file source (upload, base64, ID, or URL).
14+
*/
15+
class FileInput implements Rule
16+
{
17+
/**
18+
* The validation error message.
19+
*/
20+
protected string $message = 'The :attribute must be a valid file upload, base64 string, file ID, or URL.';
21+
22+
/**
23+
* Determine if the validation rule passes.
24+
*
25+
* @param string $attribute
26+
*/
27+
public function passes($attribute, $value): bool
28+
{
29+
// Check for UploadedFile
30+
if ($value instanceof UploadedFile) {
31+
return $value->isValid();
32+
}
33+
34+
if (is_string($value)) {
35+
// Check for public ID
36+
if (Utils::isPublicId($value)) {
37+
return true;
38+
}
39+
40+
// Check for Base64 data URI
41+
if (Str::startsWith($value, 'data:image') || Str::startsWith($value, 'data:application')) {
42+
return true;
43+
}
44+
45+
// Check for valid URL
46+
if (filter_var($value, FILTER_VALIDATE_URL)) {
47+
return true;
48+
}
49+
}
50+
51+
return false;
52+
}
53+
54+
/**
55+
* Get the validation error message.
56+
*/
57+
public function message(): string
58+
{
59+
return $this->message;
60+
}
61+
}

0 commit comments

Comments
 (0)