Skip to content

Commit 8a239ff

Browse files
author
Jad Joubran
committed
Added Response Macro for API - version 1.2.2
1 parent 8b61581 commit 8a239ff

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php namespace App\Providers;
2+
3+
use Response;
4+
use Illuminate\Support\ServiceProvider;
5+
6+
class ResponseMacroServiceProvider extends ServiceProvider {
7+
8+
/**
9+
* Bootstrap the application services.
10+
*
11+
* @return void
12+
*/
13+
public function boot()
14+
{
15+
Response::macro('api', function($data)
16+
{
17+
return Response::json(['data' => $data]);
18+
});
19+
}
20+
21+
/**
22+
* Register the application services.
23+
*
24+
* @return void
25+
*/
26+
public function register()
27+
{
28+
//
29+
}
30+
31+
}

config/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@
147147

148148
'Barryvdh\Debugbar\ServiceProvider',
149149

150+
'App\Providers\ResponseMacroServiceProvider',
151+
150152
],
151153

152154
/*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.2.1",
2+
"version": "1.2.2",
33
"devDependencies": {
44
"gulp": "^3.8.8",
55
"laravel-elixir": "*",

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ Here's what I'm planning for the next versions:
5454

5555
## Changelog
5656

57+
### v1.2.2
58+
59+
+ API response macro (to make API calls more compatible with Restangular)
60+
61+
5762
### v1.2.1
5863

5964
+ Remove unused dependency in package.json

0 commit comments

Comments
 (0)