A different way to version api output with laravel?












0















I'm about to ...




  1. extend my App/Orm/MyModel.php with Http/Json/V1/MyModel.php so I can keep the $appends, $hides, toArray() neatly tucked away in a V1

  2. namespace and prefix some routing for V1

  3. probably do some custom resolvers for route model binding


And I'm thinking ... really? They haven't built this in... what am I missing here? There's gotta be a quick, turn-key for this. I'm interested in knowing how other people are doing this, so please chime in.










share|improve this question

























  • Are you in the need of v2 already? Most likely you won't pass by v1, so just stick with non-versioned API and when times come you can refactor.

    – Kyslik
    Nov 21 '18 at 16:13













  • @Kyslik just planning ahead.

    – Tarek Adam
    Nov 21 '18 at 16:31






  • 1





    Wasting your time, imagine you have v1 and its doing fine; now you decide to develop v2; whats the process? You need to copy "all the files" and change the namespace and some more stuff above (middleware / service providers / routes) and now you can start working with v2. Can't you do that later when its actually needed? v1 will have no special namespace and v2 will have thats it.

    – Kyslik
    Nov 21 '18 at 16:34











  • @Kyslik This is just for output versioning.

    – Tarek Adam
    Nov 21 '18 at 16:44






  • 1





    @Kyslik That would be epically hilarious if you actually checked in next year - lol. And epically sad if I find myself still sitting in this same spot tapping away at a keyboard.

    – Tarek Adam
    Nov 21 '18 at 16:54
















0















I'm about to ...




  1. extend my App/Orm/MyModel.php with Http/Json/V1/MyModel.php so I can keep the $appends, $hides, toArray() neatly tucked away in a V1

  2. namespace and prefix some routing for V1

  3. probably do some custom resolvers for route model binding


And I'm thinking ... really? They haven't built this in... what am I missing here? There's gotta be a quick, turn-key for this. I'm interested in knowing how other people are doing this, so please chime in.










share|improve this question

























  • Are you in the need of v2 already? Most likely you won't pass by v1, so just stick with non-versioned API and when times come you can refactor.

    – Kyslik
    Nov 21 '18 at 16:13













  • @Kyslik just planning ahead.

    – Tarek Adam
    Nov 21 '18 at 16:31






  • 1





    Wasting your time, imagine you have v1 and its doing fine; now you decide to develop v2; whats the process? You need to copy "all the files" and change the namespace and some more stuff above (middleware / service providers / routes) and now you can start working with v2. Can't you do that later when its actually needed? v1 will have no special namespace and v2 will have thats it.

    – Kyslik
    Nov 21 '18 at 16:34











  • @Kyslik This is just for output versioning.

    – Tarek Adam
    Nov 21 '18 at 16:44






  • 1





    @Kyslik That would be epically hilarious if you actually checked in next year - lol. And epically sad if I find myself still sitting in this same spot tapping away at a keyboard.

    – Tarek Adam
    Nov 21 '18 at 16:54














0












0








0


1






I'm about to ...




  1. extend my App/Orm/MyModel.php with Http/Json/V1/MyModel.php so I can keep the $appends, $hides, toArray() neatly tucked away in a V1

  2. namespace and prefix some routing for V1

  3. probably do some custom resolvers for route model binding


And I'm thinking ... really? They haven't built this in... what am I missing here? There's gotta be a quick, turn-key for this. I'm interested in knowing how other people are doing this, so please chime in.










share|improve this question
















I'm about to ...




  1. extend my App/Orm/MyModel.php with Http/Json/V1/MyModel.php so I can keep the $appends, $hides, toArray() neatly tucked away in a V1

  2. namespace and prefix some routing for V1

  3. probably do some custom resolvers for route model binding


And I'm thinking ... really? They haven't built this in... what am I missing here? There's gotta be a quick, turn-key for this. I'm interested in knowing how other people are doing this, so please chime in.







laravel api versioning






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 20:37







Tarek Adam

















asked Nov 21 '18 at 15:11









Tarek AdamTarek Adam

8791727




8791727













  • Are you in the need of v2 already? Most likely you won't pass by v1, so just stick with non-versioned API and when times come you can refactor.

    – Kyslik
    Nov 21 '18 at 16:13













  • @Kyslik just planning ahead.

    – Tarek Adam
    Nov 21 '18 at 16:31






  • 1





    Wasting your time, imagine you have v1 and its doing fine; now you decide to develop v2; whats the process? You need to copy "all the files" and change the namespace and some more stuff above (middleware / service providers / routes) and now you can start working with v2. Can't you do that later when its actually needed? v1 will have no special namespace and v2 will have thats it.

    – Kyslik
    Nov 21 '18 at 16:34











  • @Kyslik This is just for output versioning.

    – Tarek Adam
    Nov 21 '18 at 16:44






  • 1





    @Kyslik That would be epically hilarious if you actually checked in next year - lol. And epically sad if I find myself still sitting in this same spot tapping away at a keyboard.

    – Tarek Adam
    Nov 21 '18 at 16:54



















  • Are you in the need of v2 already? Most likely you won't pass by v1, so just stick with non-versioned API and when times come you can refactor.

    – Kyslik
    Nov 21 '18 at 16:13













  • @Kyslik just planning ahead.

    – Tarek Adam
    Nov 21 '18 at 16:31






  • 1





    Wasting your time, imagine you have v1 and its doing fine; now you decide to develop v2; whats the process? You need to copy "all the files" and change the namespace and some more stuff above (middleware / service providers / routes) and now you can start working with v2. Can't you do that later when its actually needed? v1 will have no special namespace and v2 will have thats it.

    – Kyslik
    Nov 21 '18 at 16:34











  • @Kyslik This is just for output versioning.

    – Tarek Adam
    Nov 21 '18 at 16:44






  • 1





    @Kyslik That would be epically hilarious if you actually checked in next year - lol. And epically sad if I find myself still sitting in this same spot tapping away at a keyboard.

    – Tarek Adam
    Nov 21 '18 at 16:54

















Are you in the need of v2 already? Most likely you won't pass by v1, so just stick with non-versioned API and when times come you can refactor.

– Kyslik
Nov 21 '18 at 16:13







Are you in the need of v2 already? Most likely you won't pass by v1, so just stick with non-versioned API and when times come you can refactor.

– Kyslik
Nov 21 '18 at 16:13















@Kyslik just planning ahead.

– Tarek Adam
Nov 21 '18 at 16:31





@Kyslik just planning ahead.

– Tarek Adam
Nov 21 '18 at 16:31




1




1





Wasting your time, imagine you have v1 and its doing fine; now you decide to develop v2; whats the process? You need to copy "all the files" and change the namespace and some more stuff above (middleware / service providers / routes) and now you can start working with v2. Can't you do that later when its actually needed? v1 will have no special namespace and v2 will have thats it.

– Kyslik
Nov 21 '18 at 16:34





Wasting your time, imagine you have v1 and its doing fine; now you decide to develop v2; whats the process? You need to copy "all the files" and change the namespace and some more stuff above (middleware / service providers / routes) and now you can start working with v2. Can't you do that later when its actually needed? v1 will have no special namespace and v2 will have thats it.

– Kyslik
Nov 21 '18 at 16:34













@Kyslik This is just for output versioning.

– Tarek Adam
Nov 21 '18 at 16:44





@Kyslik This is just for output versioning.

– Tarek Adam
Nov 21 '18 at 16:44




1




1





@Kyslik That would be epically hilarious if you actually checked in next year - lol. And epically sad if I find myself still sitting in this same spot tapping away at a keyboard.

– Tarek Adam
Nov 21 '18 at 16:54





@Kyslik That would be epically hilarious if you actually checked in next year - lol. And epically sad if I find myself still sitting in this same spot tapping away at a keyboard.

– Tarek Adam
Nov 21 '18 at 16:54












1 Answer
1






active

oldest

votes


















2














Try Resources instead of Models



Have a look at resources:
https://laravel.com/docs/5.7/eloquent-resources



And add your logic to resources so that you display different versions of a model depending on the API version. You can still make use of $appends and $hidden.



With this approach we return a Resource of a model rather than the model itself.



Here is an example of a UserResource for different API versions:



class UserResource extends JsonResource
{
private $apiVersion;

public function __construct($resource, int $apiVersion = 2) {
$this->apiVersion = $apiVersion; // OPTION 1: Pass API version in the constructor
parent::__construct($resource);
}

public function toArray($request): array
{
// OPTION 2: Get API version in the request (ideally header)
// $apiVersion = $request->header('x-api-version', 2);

/** @var User $user */
$user = $this->resource;

return [
'type' => 'user',
'id' => $user->id,
$this->mergeWhen($this->apiVersion < 2, [
'name' => "{$user->first_name} {$user->last_name}",
], [
'name' => [
'first' => $user->first_name,
'last' => $user->last_name
],
]),
'score' => $user->score,
];
}
}


The you can call:



$user = User::find(5);
return new UserResource($user);


If you need a different connection you can do:



$user = User::on('second_db_connection')->find(5);


So V1 API gets:



{
id: 5,
name: "John Smith",
score: 5
}


and V2 API gets:



{
id: 5,
name: {
first: "John",
last: "Smith",
},
score: 5
}


Now if later you wanted to rename score to points in your DB, and in V3 of your API you also wanted to change your JSON output, but maintain backwards compatibility you can do:



   $this->mergeWhen($this->apiVersion < 3, [
'score' => $user->points,
], [
'points' => $user->points,
])


Prefix routes



You can easily prefix routes as mentioned here: https://laravel.com/docs/5.7/routing#route-group-prefixes



Route::prefix('v1')->group(function () {
Route::get('users', function () {
// ...
});
});


Explicit Route Model Binding



To do custom route model bindings have a look at: https://laravel.com/docs/5.7/routing#route-model-binding



e.g.



Route::bind('user', function ($value) {
return AppUser::where('name', $value)->first() ?? abort(404); // your customer logic
});





share|improve this answer


























  • Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

    – Tarek Adam
    Nov 21 '18 at 16:41











  • @TarekAdam Please mark this answer as correct if it solved your problem

    – Yahya Uddin
    Nov 21 '18 at 17:09













  • Still looking into the issue.

    – Tarek Adam
    Nov 21 '18 at 19:13











  • Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

    – Tarek Adam
    Nov 21 '18 at 21:17






  • 1





    Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

    – Yahya Uddin
    Nov 22 '18 at 18:36











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415035%2fa-different-way-to-version-api-output-with-laravel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Try Resources instead of Models



Have a look at resources:
https://laravel.com/docs/5.7/eloquent-resources



And add your logic to resources so that you display different versions of a model depending on the API version. You can still make use of $appends and $hidden.



With this approach we return a Resource of a model rather than the model itself.



Here is an example of a UserResource for different API versions:



class UserResource extends JsonResource
{
private $apiVersion;

public function __construct($resource, int $apiVersion = 2) {
$this->apiVersion = $apiVersion; // OPTION 1: Pass API version in the constructor
parent::__construct($resource);
}

public function toArray($request): array
{
// OPTION 2: Get API version in the request (ideally header)
// $apiVersion = $request->header('x-api-version', 2);

/** @var User $user */
$user = $this->resource;

return [
'type' => 'user',
'id' => $user->id,
$this->mergeWhen($this->apiVersion < 2, [
'name' => "{$user->first_name} {$user->last_name}",
], [
'name' => [
'first' => $user->first_name,
'last' => $user->last_name
],
]),
'score' => $user->score,
];
}
}


The you can call:



$user = User::find(5);
return new UserResource($user);


If you need a different connection you can do:



$user = User::on('second_db_connection')->find(5);


So V1 API gets:



{
id: 5,
name: "John Smith",
score: 5
}


and V2 API gets:



{
id: 5,
name: {
first: "John",
last: "Smith",
},
score: 5
}


Now if later you wanted to rename score to points in your DB, and in V3 of your API you also wanted to change your JSON output, but maintain backwards compatibility you can do:



   $this->mergeWhen($this->apiVersion < 3, [
'score' => $user->points,
], [
'points' => $user->points,
])


Prefix routes



You can easily prefix routes as mentioned here: https://laravel.com/docs/5.7/routing#route-group-prefixes



Route::prefix('v1')->group(function () {
Route::get('users', function () {
// ...
});
});


Explicit Route Model Binding



To do custom route model bindings have a look at: https://laravel.com/docs/5.7/routing#route-model-binding



e.g.



Route::bind('user', function ($value) {
return AppUser::where('name', $value)->first() ?? abort(404); // your customer logic
});





share|improve this answer


























  • Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

    – Tarek Adam
    Nov 21 '18 at 16:41











  • @TarekAdam Please mark this answer as correct if it solved your problem

    – Yahya Uddin
    Nov 21 '18 at 17:09













  • Still looking into the issue.

    – Tarek Adam
    Nov 21 '18 at 19:13











  • Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

    – Tarek Adam
    Nov 21 '18 at 21:17






  • 1





    Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

    – Yahya Uddin
    Nov 22 '18 at 18:36
















2














Try Resources instead of Models



Have a look at resources:
https://laravel.com/docs/5.7/eloquent-resources



And add your logic to resources so that you display different versions of a model depending on the API version. You can still make use of $appends and $hidden.



With this approach we return a Resource of a model rather than the model itself.



Here is an example of a UserResource for different API versions:



class UserResource extends JsonResource
{
private $apiVersion;

public function __construct($resource, int $apiVersion = 2) {
$this->apiVersion = $apiVersion; // OPTION 1: Pass API version in the constructor
parent::__construct($resource);
}

public function toArray($request): array
{
// OPTION 2: Get API version in the request (ideally header)
// $apiVersion = $request->header('x-api-version', 2);

/** @var User $user */
$user = $this->resource;

return [
'type' => 'user',
'id' => $user->id,
$this->mergeWhen($this->apiVersion < 2, [
'name' => "{$user->first_name} {$user->last_name}",
], [
'name' => [
'first' => $user->first_name,
'last' => $user->last_name
],
]),
'score' => $user->score,
];
}
}


The you can call:



$user = User::find(5);
return new UserResource($user);


If you need a different connection you can do:



$user = User::on('second_db_connection')->find(5);


So V1 API gets:



{
id: 5,
name: "John Smith",
score: 5
}


and V2 API gets:



{
id: 5,
name: {
first: "John",
last: "Smith",
},
score: 5
}


Now if later you wanted to rename score to points in your DB, and in V3 of your API you also wanted to change your JSON output, but maintain backwards compatibility you can do:



   $this->mergeWhen($this->apiVersion < 3, [
'score' => $user->points,
], [
'points' => $user->points,
])


Prefix routes



You can easily prefix routes as mentioned here: https://laravel.com/docs/5.7/routing#route-group-prefixes



Route::prefix('v1')->group(function () {
Route::get('users', function () {
// ...
});
});


Explicit Route Model Binding



To do custom route model bindings have a look at: https://laravel.com/docs/5.7/routing#route-model-binding



e.g.



Route::bind('user', function ($value) {
return AppUser::where('name', $value)->first() ?? abort(404); // your customer logic
});





share|improve this answer


























  • Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

    – Tarek Adam
    Nov 21 '18 at 16:41











  • @TarekAdam Please mark this answer as correct if it solved your problem

    – Yahya Uddin
    Nov 21 '18 at 17:09













  • Still looking into the issue.

    – Tarek Adam
    Nov 21 '18 at 19:13











  • Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

    – Tarek Adam
    Nov 21 '18 at 21:17






  • 1





    Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

    – Yahya Uddin
    Nov 22 '18 at 18:36














2












2








2







Try Resources instead of Models



Have a look at resources:
https://laravel.com/docs/5.7/eloquent-resources



And add your logic to resources so that you display different versions of a model depending on the API version. You can still make use of $appends and $hidden.



With this approach we return a Resource of a model rather than the model itself.



Here is an example of a UserResource for different API versions:



class UserResource extends JsonResource
{
private $apiVersion;

public function __construct($resource, int $apiVersion = 2) {
$this->apiVersion = $apiVersion; // OPTION 1: Pass API version in the constructor
parent::__construct($resource);
}

public function toArray($request): array
{
// OPTION 2: Get API version in the request (ideally header)
// $apiVersion = $request->header('x-api-version', 2);

/** @var User $user */
$user = $this->resource;

return [
'type' => 'user',
'id' => $user->id,
$this->mergeWhen($this->apiVersion < 2, [
'name' => "{$user->first_name} {$user->last_name}",
], [
'name' => [
'first' => $user->first_name,
'last' => $user->last_name
],
]),
'score' => $user->score,
];
}
}


The you can call:



$user = User::find(5);
return new UserResource($user);


If you need a different connection you can do:



$user = User::on('second_db_connection')->find(5);


So V1 API gets:



{
id: 5,
name: "John Smith",
score: 5
}


and V2 API gets:



{
id: 5,
name: {
first: "John",
last: "Smith",
},
score: 5
}


Now if later you wanted to rename score to points in your DB, and in V3 of your API you also wanted to change your JSON output, but maintain backwards compatibility you can do:



   $this->mergeWhen($this->apiVersion < 3, [
'score' => $user->points,
], [
'points' => $user->points,
])


Prefix routes



You can easily prefix routes as mentioned here: https://laravel.com/docs/5.7/routing#route-group-prefixes



Route::prefix('v1')->group(function () {
Route::get('users', function () {
// ...
});
});


Explicit Route Model Binding



To do custom route model bindings have a look at: https://laravel.com/docs/5.7/routing#route-model-binding



e.g.



Route::bind('user', function ($value) {
return AppUser::where('name', $value)->first() ?? abort(404); // your customer logic
});





share|improve this answer















Try Resources instead of Models



Have a look at resources:
https://laravel.com/docs/5.7/eloquent-resources



And add your logic to resources so that you display different versions of a model depending on the API version. You can still make use of $appends and $hidden.



With this approach we return a Resource of a model rather than the model itself.



Here is an example of a UserResource for different API versions:



class UserResource extends JsonResource
{
private $apiVersion;

public function __construct($resource, int $apiVersion = 2) {
$this->apiVersion = $apiVersion; // OPTION 1: Pass API version in the constructor
parent::__construct($resource);
}

public function toArray($request): array
{
// OPTION 2: Get API version in the request (ideally header)
// $apiVersion = $request->header('x-api-version', 2);

/** @var User $user */
$user = $this->resource;

return [
'type' => 'user',
'id' => $user->id,
$this->mergeWhen($this->apiVersion < 2, [
'name' => "{$user->first_name} {$user->last_name}",
], [
'name' => [
'first' => $user->first_name,
'last' => $user->last_name
],
]),
'score' => $user->score,
];
}
}


The you can call:



$user = User::find(5);
return new UserResource($user);


If you need a different connection you can do:



$user = User::on('second_db_connection')->find(5);


So V1 API gets:



{
id: 5,
name: "John Smith",
score: 5
}


and V2 API gets:



{
id: 5,
name: {
first: "John",
last: "Smith",
},
score: 5
}


Now if later you wanted to rename score to points in your DB, and in V3 of your API you also wanted to change your JSON output, but maintain backwards compatibility you can do:



   $this->mergeWhen($this->apiVersion < 3, [
'score' => $user->points,
], [
'points' => $user->points,
])


Prefix routes



You can easily prefix routes as mentioned here: https://laravel.com/docs/5.7/routing#route-group-prefixes



Route::prefix('v1')->group(function () {
Route::get('users', function () {
// ...
});
});


Explicit Route Model Binding



To do custom route model bindings have a look at: https://laravel.com/docs/5.7/routing#route-model-binding



e.g.



Route::bind('user', function ($value) {
return AppUser::where('name', $value)->first() ?? abort(404); // your customer logic
});






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 '18 at 20:44









Tarek Adam

8791727




8791727










answered Nov 21 '18 at 16:11









Yahya UddinYahya Uddin

5,9621455112




5,9621455112













  • Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

    – Tarek Adam
    Nov 21 '18 at 16:41











  • @TarekAdam Please mark this answer as correct if it solved your problem

    – Yahya Uddin
    Nov 21 '18 at 17:09













  • Still looking into the issue.

    – Tarek Adam
    Nov 21 '18 at 19:13











  • Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

    – Tarek Adam
    Nov 21 '18 at 21:17






  • 1





    Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

    – Yahya Uddin
    Nov 22 '18 at 18:36



















  • Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

    – Tarek Adam
    Nov 21 '18 at 16:41











  • @TarekAdam Please mark this answer as correct if it solved your problem

    – Yahya Uddin
    Nov 21 '18 at 17:09













  • Still looking into the issue.

    – Tarek Adam
    Nov 21 '18 at 19:13











  • Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

    – Tarek Adam
    Nov 21 '18 at 21:17






  • 1





    Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

    – Yahya Uddin
    Nov 22 '18 at 18:36

















Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

– Tarek Adam
Nov 21 '18 at 16:41





Eloquent resource is on the right track, thanks. Looks pretty limited, but maybe sometimes limits are a good thing. Cheers!

– Tarek Adam
Nov 21 '18 at 16:41













@TarekAdam Please mark this answer as correct if it solved your problem

– Yahya Uddin
Nov 21 '18 at 17:09







@TarekAdam Please mark this answer as correct if it solved your problem

– Yahya Uddin
Nov 21 '18 at 17:09















Still looking into the issue.

– Tarek Adam
Nov 21 '18 at 19:13





Still looking into the issue.

– Tarek Adam
Nov 21 '18 at 19:13













Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

– Tarek Adam
Nov 21 '18 at 21:17





Took another look, but I'm just not seeing the benefit ~ other than ... it's light. On the drawback side, I can't set a connection - and that's a deal breaker since the Json output namespaced models will be read from slaves.

– Tarek Adam
Nov 21 '18 at 21:17




1




1





Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

– Yahya Uddin
Nov 22 '18 at 18:36





Got it. You can specify different connections for read/ write by editing your database config file as mentioned here: laravel.com/docs/5.7/database#read-and-write-connections

– Yahya Uddin
Nov 22 '18 at 18:36




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415035%2fa-different-way-to-version-api-output-with-laravel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith