Completed
Push — master ( 509012...3eafe2 )
by David
02:34
created
app/Http/Controllers/API/V1/ApiController.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
     /**
122 122
      * Returns a single item
123 123
      * 
124
-     * @param  object $object
124
+     * @param  \Illuminate\Database\Eloquent\Model $object
125 125
      * @return \Illuminate\Http\JsonResponse
126 126
      */
127 127
     public function showByObject($object)
Please login to merge, or discard this patch.
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -4,9 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Illuminate\Database\Eloquent\ModelNotFoundException;
6 6
 use Illuminate\Contracts\Validation\ValidationException;
7
-use Illuminate\Foundation\Bus\DispatchesCommands;
8
-use Illuminate\Foundation\Validation\ValidatesRequests;
9
-use Illuminate\Routing\Controller as BaseController;
10 7
 
11 8
 use \Chrisbjr\ApiGuard\Http\Controllers\ApiGuardController;
12 9
 
Please login to merge, or discard this patch.
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -12,160 +12,160 @@
 block discarded – undo
12 12
 
13 13
 abstract class ApiController extends ApiGuardController
14 14
 {
15
-    /**
16
-     * Laraponse object, which abstracts Fractal
17
-     * 
18
-     * @var \EllipseSynergie\ApiResponse\Laravel\Response
19
-     */
20
-    public $response;
15
+	/**
16
+	 * Laraponse object, which abstracts Fractal
17
+	 * 
18
+	 * @var \EllipseSynergie\ApiResponse\Laravel\Response
19
+	 */
20
+	public $response;
21 21
     
22
-    /**
23
-     * The string name of the Eloquent Model
24
-     * 
25
-     * @var string
26
-     */
27
-    protected $modelName;
22
+	/**
23
+	 * The string name of the Eloquent Model
24
+	 * 
25
+	 * @var string
26
+	 */
27
+	protected $modelName;
28 28
     
29
-    /**
30
-     * The Eloquent Model
31
-     * 
32
-     * @var \Illuminate\Database\Eloquent\Model
33
-     */
34
-    protected $model;
29
+	/**
30
+	 * The Eloquent Model
31
+	 * 
32
+	 * @var \Illuminate\Database\Eloquent\Model
33
+	 */
34
+	protected $model;
35 35
     
36
-    /**
37
-     * The string name of the Transformer class
38
-     * 
39
-     * @var string
40
-     */
41
-    protected $transformerName;
36
+	/**
37
+	 * The string name of the Transformer class
38
+	 * 
39
+	 * @var string
40
+	 */
41
+	protected $transformerName;
42 42
     
43
-    /**
44
-     * The name of the collection that is returned in the JSON response
45
-     * 
46
-     * @var string
47
-     */
48
-    protected $collectionName;
43
+	/**
44
+	 * The name of the collection that is returned in the JSON response
45
+	 * 
46
+	 * @var string
47
+	 */
48
+	protected $collectionName;
49 49
     
50
-    /**
51
-     * The Fractal Manager
52
-     * 
53
-     * @var \League\Fractal\Manager
54
-     */
55
-    public $manager;
56
-
57
-
58
-    /**
59
-     * Constructor
60
-     */
61
-    public function __construct()
62
-    {
63
-        $this->response = \Response::api();
50
+	/**
51
+	 * The Fractal Manager
52
+	 * 
53
+	 * @var \League\Fractal\Manager
54
+	 */
55
+	public $manager;
56
+
57
+
58
+	/**
59
+	 * Constructor
60
+	 */
61
+	public function __construct()
62
+	{
63
+		$this->response = \Response::api();
64 64
         
65
-        if (!empty($this->modelName)) {
66
-            $this->model = new $this->modelName;
67
-        }
68
-
69
-        // if no collection name provided, use the model's table name
70
-        if (empty($this->collectionName)) {
71
-            $this->collectionName = $this->model->getTable();
72
-        }
65
+		if (!empty($this->modelName)) {
66
+			$this->model = new $this->modelName;
67
+		}
68
+
69
+		// if no collection name provided, use the model's table name
70
+		if (empty($this->collectionName)) {
71
+			$this->collectionName = $this->model->getTable();
72
+		}
73 73
         
74
-        // parse includes
75
-        if (\Input::get('include') != '') {
76
-            $this->manager = new \League\Fractal\Manager;
77
-            $this->manager->parseIncludes(explode(',', \Input::get('include')));
78
-        }
79
-
80
-        parent::__construct();
81
-    }
82
-
83
-    /**
84
-     * Create an item
85
-     * 
86
-     * @return \Illuminate\Http\JsonResponse
87
-     */
88
-    public function create($data = null)
89
-    {   
90
-        $data = $data ?: \Input::json()->all();
91
-
92
-        try {
93
-            $this->model->validate($data);
94
-            $item = $this->model->create($data);
74
+		// parse includes
75
+		if (\Input::get('include') != '') {
76
+			$this->manager = new \League\Fractal\Manager;
77
+			$this->manager->parseIncludes(explode(',', \Input::get('include')));
78
+		}
79
+
80
+		parent::__construct();
81
+	}
82
+
83
+	/**
84
+	 * Create an item
85
+	 * 
86
+	 * @return \Illuminate\Http\JsonResponse
87
+	 */
88
+	public function create($data = null)
89
+	{   
90
+		$data = $data ?: \Input::json()->all();
91
+
92
+		try {
93
+			$this->model->validate($data);
94
+			$item = $this->model->create($data);
95 95
             
96
-            return $this->showByObject($item);
96
+			return $this->showByObject($item);
97 97
         
98
-        } catch (ValidationException $e) {
99
-            return $this->response->setStatusCode(422)->withError($e->errors()->toArray(), 'GEN-UNPROCESSABLE-ENTITY');
100
-        }
101
-    }
102
-
103
-    /**
104
-     * Returns a single item
105
-     * 
106
-     * @param  int $id
107
-     * @return \Illuminate\Http\JsonResponse
108
-     */
109
-    public function show($id)
110
-    {        
111
-        try {
98
+		} catch (ValidationException $e) {
99
+			return $this->response->setStatusCode(422)->withError($e->errors()->toArray(), 'GEN-UNPROCESSABLE-ENTITY');
100
+		}
101
+	}
102
+
103
+	/**
104
+	 * Returns a single item
105
+	 * 
106
+	 * @param  int $id
107
+	 * @return \Illuminate\Http\JsonResponse
108
+	 */
109
+	public function show($id)
110
+	{        
111
+		try {
112 112
             
113
-            return $this->response->withItem($this->model->findOrFail($id), new $this->transformerName);
113
+			return $this->response->withItem($this->model->findOrFail($id), new $this->transformerName);
114 114
         
115
-        } catch (ModelNotFoundException $e) {
116
-
117
-            return $this->respondNotFound();
118
-        }
119
-    }
120
-
121
-    /**
122
-     * Returns a single item
123
-     * 
124
-     * @param  object $object
125
-     * @return \Illuminate\Http\JsonResponse
126
-     */
127
-    public function showByObject($object)
128
-    {        
129
-        try {
130
-            return $this->response->withItem($object, new $this->transformerName);
115
+		} catch (ModelNotFoundException $e) {
116
+
117
+			return $this->respondNotFound();
118
+		}
119
+	}
120
+
121
+	/**
122
+	 * Returns a single item
123
+	 * 
124
+	 * @param  object $object
125
+	 * @return \Illuminate\Http\JsonResponse
126
+	 */
127
+	public function showByObject($object)
128
+	{        
129
+		try {
130
+			return $this->response->withItem($object, new $this->transformerName);
131 131
         
132
-        } catch (ModelNotFoundException $e) {
133
-
134
-            return $this->respondNotFound();
135
-        }
136
-    }
137
-
138
-    /**
139
-     * Returns a paginated collection
140
-     * 
141
-     * @return \Illuminate\Http\JsonResponse
142
-     */
143
-    public function collection()
144
-    {
145
-        $limit = \Input::get('limit') ?: 10;
146
-        $model = $this->model;
132
+		} catch (ModelNotFoundException $e) {
133
+
134
+			return $this->respondNotFound();
135
+		}
136
+	}
137
+
138
+	/**
139
+	 * Returns a paginated collection
140
+	 * 
141
+	 * @return \Illuminate\Http\JsonResponse
142
+	 */
143
+	public function collection()
144
+	{
145
+		$limit = \Input::get('limit') ?: 10;
146
+		$model = $this->model;
147 147
         
148
-        if (\Request::has('order')) {
149
-            list($orderCol, $orderBy) = explode('|', \Input::get('order'));
150
-            $model = $model->orderBy($orderCol, $orderBy);
151
-        }
152
-
153
-        return $this->response->withPaginator($model->paginate($limit), new $this->transformerName, $this->collectionName);
154
-    }
155
-
156
-    /**
157
-     * Handles 404 errors
158
-     * 
159
-     * @param  string $msg
160
-     * @return \Illuminate\Http\JsonResponse
161
-     */
162
-    public function respondNotFound($msg = 'Not found!')
163
-    {
164
-        return \Response::json([
165
-            'error' => [
166
-                'message' => $msg,
167
-                'status_code' => 404
168
-            ]
169
-        ], 404);
170
-    }
148
+		if (\Request::has('order')) {
149
+			list($orderCol, $orderBy) = explode('|', \Input::get('order'));
150
+			$model = $model->orderBy($orderCol, $orderBy);
151
+		}
152
+
153
+		return $this->response->withPaginator($model->paginate($limit), new $this->transformerName, $this->collectionName);
154
+	}
155
+
156
+	/**
157
+	 * Handles 404 errors
158
+	 * 
159
+	 * @param  string $msg
160
+	 * @return \Illuminate\Http\JsonResponse
161
+	 */
162
+	public function respondNotFound($msg = 'Not found!')
163
+	{
164
+		return \Response::json([
165
+			'error' => [
166
+				'message' => $msg,
167
+				'status_code' => 404
168
+			]
169
+		], 404);
170
+	}
171 171
 }
172 172
\ No newline at end of file
Please login to merge, or discard this patch.
app/LaravelRestCms/Page/PageDetailTransformer.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     /**
20 20
      * Include Template Detail
21 21
      *
22
-     * @return \League\Fractal\ItemResource
22
+     * @return \League\Fractal\Resource\Collection
23 23
      */
24 24
     public function includeTemplateDetail(PageDetail $pageDetail)
25 25
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php namespace App\LaravelRestCms\Page;
2 2
 
3
-use App\LaravelRestCms\BaseModel;
4 3
 use App\LaravelRestCms\BaseTransformer;
5 4
 use App\LaravelRestCms\Page\PageDetail;
6 5
 use App\LaravelRestCms\Template\TemplateDetailTransformer;
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
 		'template_detail'
17 17
 	];
18 18
 
19
-    /**
20
-     * Include Template Detail
21
-     *
22
-     * @return \League\Fractal\ItemResource
23
-     */
24
-    public function includeTemplateDetail(PageDetail $pageDetail)
25
-    {
26
-        return $this->collection($pageDetail->templateDetail, new TemplateDetailTransformer);
27
-    }
19
+	/**
20
+	 * Include Template Detail
21
+	 *
22
+	 * @return \League\Fractal\ItemResource
23
+	 */
24
+	public function includeTemplateDetail(PageDetail $pageDetail)
25
+	{
26
+		return $this->collection($pageDetail->templateDetail, new TemplateDetailTransformer);
27
+	}
28 28
 }
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
app/LaravelRestCms/Page/PageTransformer.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * Include Page Detail
23 23
      * 
24 24
      * @param \App\LaravelRestCms\Page\Page
25
-     * @return \League\Fractal\ItemResource
25
+     * @return \League\Fractal\Resource\Collection
26 26
      */
27 27
     public function includeDetail(Page $page)
28 28
     {
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * Include Template
34 34
      *
35 35
      * @param \App\LaravelRestCms\Page\Page
36
-     * @return \League\Fractal\ItemResource
36
+     * @return \League\Fractal\Resource\Collection
37 37
      */
38 38
     public function includeTemplate(Page $page)
39 39
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php namespace App\LaravelRestCms\Page;
2 2
 
3
-use App\LaravelRestCms\BaseModel;
4 3
 use App\LaravelRestCms\BaseTransformer;
5 4
 use App\LaravelRestCms\Page\Page;
6 5
 use App\LaravelRestCms\Page\PageDetailTransformer;
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,25 +18,25 @@
 block discarded – undo
18 18
 		'template',
19 19
 	];
20 20
 
21
-    /**
22
-     * Include Page Detail
23
-     * 
24
-     * @param \App\LaravelRestCms\Page\Page
25
-     * @return \League\Fractal\ItemResource
26
-     */
27
-    public function includeDetail(Page $page)
28
-    {
29
-        return $this->collection($page->detail, new PageDetailTransformer);
30
-    }
21
+	/**
22
+	 * Include Page Detail
23
+	 * 
24
+	 * @param \App\LaravelRestCms\Page\Page
25
+	 * @return \League\Fractal\ItemResource
26
+	 */
27
+	public function includeDetail(Page $page)
28
+	{
29
+		return $this->collection($page->detail, new PageDetailTransformer);
30
+	}
31 31
 
32
-    /**
33
-     * Include Template
34
-     *
35
-     * @param \App\LaravelRestCms\Page\Page
36
-     * @return \League\Fractal\ItemResource
37
-     */
38
-    public function includeTemplate(Page $page)
39
-    {
40
-        return $this->collection($page->template, new TemplateTransformer);
41
-    }
32
+	/**
33
+	 * Include Template
34
+	 *
35
+	 * @param \App\LaravelRestCms\Page\Page
36
+	 * @return \League\Fractal\ItemResource
37
+	 */
38
+	public function includeTemplate(Page $page)
39
+	{
40
+		return $this->collection($page->template, new TemplateTransformer);
41
+	}
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
app/LaravelRestCms/Template/Template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
35 35
 	 */
36 36
 	public function detail()
37
-    {
38
-        return $this->hasMany(TemplateDetail::class, 'template_id', 'id');
39
-    }
37
+	{
38
+		return $this->hasMany(TemplateDetail::class, 'template_id', 'id');
39
+	}
40 40
     
41 41
 }
Please login to merge, or discard this patch.
app/LaravelRestCms/Page/PageDetail.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 	 * @return \Illuminate\Database\Eloquent\Relations\HasOne
35 35
 	 */
36 36
 	public function templateDetail()
37
-    {
38
-        return $this->hasMany(TemplateDetail::class, 'id', 'template_detail_id');
39
-    }
37
+	{
38
+		return $this->hasMany(TemplateDetail::class, 'id', 'template_detail_id');
39
+	}
40 40
 
41 41
 }
Please login to merge, or discard this patch.
app/LaravelRestCms/Page/Page.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
36 36
 	 */
37 37
 	public function detail()
38
-    {
39
-        return $this->hasMany(PageDetail::class, 'page_id', 'id');
40
-    }
38
+	{
39
+		return $this->hasMany(PageDetail::class, 'page_id', 'id');
40
+	}
41 41
 
42 42
 	/**
43 43
 	 * Joins the templates table
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @return \Illuminate\Database\Eloquent\Relations\hasOne
46 46
 	 */
47 47
 	public function template()
48
-    {
49
-        return $this->hasMany(Template::class, 'id', 'template_id');
50
-    }
48
+	{
49
+		return $this->hasMany(Template::class, 'id', 'template_id');
50
+	}
51 51
 
52 52
 }
Please login to merge, or discard this patch.
app/Library/Xml.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 	 * 
64 64
 	 * @param  string $xml 
65 65
 	 * @return \SimpleXMLElement
66
-     */
66
+	 */
67 67
 	public function toXml($xml, $namespace = null)
68 68
 	{       
69 69
 		$xml = $xml ?: $this->xml;
Please login to merge, or discard this patch.