diff --git a/src/Http/Controllers/Api/v1/OrganizationController.php b/src/Http/Controllers/Api/v1/OrganizationController.php index 875bdd5..0940bc7 100644 --- a/src/Http/Controllers/Api/v1/OrganizationController.php +++ b/src/Http/Controllers/Api/v1/OrganizationController.php @@ -2,21 +2,21 @@ namespace Fleetbase\Http\Controllers\Api\v1; -use Illuminate\Http\Request; use Fleetbase\Http\Controllers\Controller; use Fleetbase\Http\Resources\Organization; use Fleetbase\Models\ApiCredential; use Fleetbase\Models\Company; +use Illuminate\Http\Request; use Illuminate\Support\Str; class OrganizationController extends Controller { public function getOrganization(Request $request) { - $token = $request->bearerToken(); + $token = $request->bearerToken(); $isSecretKey = Str::startsWith($token, '$'); - // Depending on API key format set the connection to find credential on + // Depending on API key format set the connection to find credential on $connection = Str::startsWith($token, 'flb_test_') ? 'sandbox' : 'mysql'; // Find the API Credential record @@ -41,7 +41,7 @@ public function getOrganization(Request $request) // Get the organization owning the API key $organization = Company::where('uuid', $apiCredential->company_uuid)->first(); - + return new Organization($organization); } } diff --git a/src/Http/Resources/Organization.php b/src/Http/Resources/Organization.php index fa81bdf..e24e99e 100644 --- a/src/Http/Resources/Organization.php +++ b/src/Http/Resources/Organization.php @@ -2,9 +2,8 @@ namespace Fleetbase\Http\Resources; -use Fleetbase\Support\Http; use Fleetbase\Models\Setting; - +use Fleetbase\Support\Http; class Organization extends FleetbaseResource { diff --git a/src/Support/Utils.php b/src/Support/Utils.php index 1e51115..baf1d5e 100644 --- a/src/Support/Utils.php +++ b/src/Support/Utils.php @@ -2158,10 +2158,11 @@ public static function getDefaultMailFromAddress(?string $default = 'hello@fleet * * This function checks if the given URL starts with 'http://' or 'https://'. * If it does, it parses the URL and adds 'www.' to the host part if it's not already there. - * If the URL does not start with 'http://' or 'https://', it simply checks if 'www.' is + * If the URL does not start with 'http://' or 'https://', it simply checks if 'www.' is * already present at the start of the URL. If not, it adds 'www.'. * * @param string $url The URL to which 'www.' should be added if it's not already present. + * * @return string The modified URL with 'www.' added if it was absent. * * Example usage: diff --git a/src/Traits/Expandable.php b/src/Traits/Expandable.php index 6e770f8..7479401 100644 --- a/src/Traits/Expandable.php +++ b/src/Traits/Expandable.php @@ -3,7 +3,6 @@ namespace Fleetbase\Traits; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Str; trait Expandable { diff --git a/src/Traits/HasMetaAttributes.php b/src/Traits/HasMetaAttributes.php index 9561d39..62315a8 100644 --- a/src/Traits/HasMetaAttributes.php +++ b/src/Traits/HasMetaAttributes.php @@ -111,6 +111,7 @@ public function updateMeta($key, $value = null) $meta[$key] = static::prepareValue($value); $this->setAttribute('meta', $meta); + return $this->update(['meta' => $meta]); } @@ -120,7 +121,7 @@ public function updateMetaProperties(array $data = []) $currentMetaObject = array_merge($currentMetaObject, $data); return DB::table($this->getTable())->where($this->getKeyName(), $this->getKey())->update([ - 'meta' => json_encode($currentMetaObject) + 'meta' => json_encode($currentMetaObject), ]); } diff --git a/src/routes.php b/src/routes.php index 7a1daad..f917bf1 100644 --- a/src/routes.php +++ b/src/routes.php @@ -21,7 +21,7 @@ function ($router) { $router->get('/', 'Controller@hello'); - /* + /* |-------------------------------------------------------------------------- | Public/Consumable Routes |-------------------------------------------------------------------------- @@ -29,10 +29,10 @@ function ($router) { | Routes for users and public applications to consume. */ $router->prefix('v1') - ->namespace('Api\v1') - ->group(function ($router) { - $router->get('organizations','OrganizationController@getOrganization'); - }); + ->namespace('Api\v1') + ->group(function ($router) { + $router->get('organizations', 'OrganizationController@getOrganization'); + }); /* |--------------------------------------------------------------------------