Completed
Push — master ( 4560a8...509012 )
by David
06:25
created
app/Http/Controllers/API/V1/ApiController.php 1 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 Eloquen Model
24
-     * 
25
-     * @var string
26
-     */
27
-    protected $modelName;
22
+	/**
23
+	 * The string name of the Eloquen 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/SearchTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 	public function scopeSearch($query, $keyword = null) 
65 65
 	{        
66 66
 		$searchCols = $this->getSearchCols(null, static::$labelCol);
67
-		$query->select('*', implode(' ', static::$labelCol) .  ' as label', 'url');
67
+		$query->select('*', implode(' ', static::$labelCol) . ' as label', 'url');
68 68
 		$match = '';
69 69
 
70 70
 		// make search results use the "and" clause
Please login to merge, or discard this patch.
app/Console/Commands/CallRoute.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 
21 21
 	public function fire()
22 22
 	{
23
-		$request = Request::create((string)$this->option('uri'), 'GET');
23
+		$request = Request::create((string) $this->option('uri'), 'GET');
24 24
 		$request->headers->set('X-Authorization', $this->option('token'));
25 25
 		$this->info(strip_tags(
26 26
 			app()['Illuminate\Contracts\Http\Kernel']->handle($request)
Please login to merge, or discard this patch.
app/Library/Sftp.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -7,154 +7,154 @@
 block discarded – undo
7 7
 class Sftp
8 8
 {
9 9
     
10
-    protected $connectionName;
11
-
12
-    /**
13
-     * Constructor
14
-     *
15
-     * @param string $connectionName
16
-     */
17
-    public function __construct($connectionName)
18
-    {
19
-        $this->connectionName = $connectionName;
20
-    }
21
-
22
-    /**
23
-     * Gets all XML files from a remote folder
24
-     * 
25
-     * @param  string $remoteDir 
26
-     * @param  string $localDir 
27
-     * @return array
28
-     */
10
+	protected $connectionName;
11
+
12
+	/**
13
+	 * Constructor
14
+	 *
15
+	 * @param string $connectionName
16
+	 */
17
+	public function __construct($connectionName)
18
+	{
19
+		$this->connectionName = $connectionName;
20
+	}
21
+
22
+	/**
23
+	 * Gets all XML files from a remote folder
24
+	 * 
25
+	 * @param  string $remoteDir 
26
+	 * @param  string $localDir 
27
+	 * @return array
28
+	 */
29 29
    	public function getFiles($remoteDir, $localDir)
30 30
    	{    	
31
-    	$files = $this->remoteListPackaged($remoteDir);
31
+		$files = $this->remoteListPackaged($remoteDir);
32 32
 
33
-    	foreach ($files as $file) {			
33
+		foreach ($files as $file) {			
34 34
 			$this->getFile($file['fullFileName'], $localDir . '/' . $file['fileName']);
35 35
 		}
36 36
 
37
-    	return $files;
37
+		return $files;
38 38
   	}
39 39
 
40
-    /**
41
-     * Gets all XML files from a remote folder
42
-     * 
43
-     * @param  string 	$dir 
44
-     * @param  bool     $sorted 
45
-     * @param  string   $sortOrder 
46
-     * @return array
47
-     */
40
+	/**
41
+	 * Gets all XML files from a remote folder
42
+	 * 
43
+	 * @param  string 	$dir 
44
+	 * @param  bool     $sorted 
45
+	 * @param  string   $sortOrder 
46
+	 * @return array
47
+	 */
48 48
    	public function remoteListPackaged($dir, $sorted = true, $sortOrder = 'desc')
49 49
    	{    	
50
-    	$files = [];
50
+		$files = [];
51 51
 		$all = $this->remoteList($dir, $sorted, $sortOrder);
52 52
 		
53
-        foreach ($all as $file=>$val) {
53
+		foreach ($all as $file=>$val) {
54 54
 			if ($this->isValidExtension($val['filename'])) {
55 55
 				$files[] = [
56
-                    'fileName' => $val['filename'], 
57
-                    'fullFileName' => $dir . '/' . $val['filename'],
58
-                    'size' => $val['size'],
59
-                    'modified' => gmdate("m/d/Y H:i:s", $val['mtime']),
60
-                ];
56
+					'fileName' => $val['filename'], 
57
+					'fullFileName' => $dir . '/' . $val['filename'],
58
+					'size' => $val['size'],
59
+					'modified' => gmdate("m/d/Y H:i:s", $val['mtime']),
60
+				];
61 61
 			}
62 62
 		}
63 63
 
64 64
 		return $files;
65
-    }
65
+	}
66 66
 
67
-    /**
68
-     * Retrieves a file from a SSH/SFTP server
69
-     * 
70
-     * @param  string $remoteFile 
71
-     * @param  string $localFile 
67
+	/**
68
+	 * Retrieves a file from a SSH/SFTP server
69
+	 * 
70
+	 * @param  string $remoteFile 
71
+	 * @param  string $localFile 
72 72
 	 * @return \Symfony\Component\Console\Output\OutputInterface
73
-     */
74
-    public function getFile($remoteFile, $localFile)
75
-    {	
76
-    	return \SSH::into($this->connectionName)->get($remoteFile, $localFile);    
77
-    }
78
-
79
-    /**
80
-     * Places a file on a remote SSH/SFTP server
81
-     * 
82
-     * @param  string $remoteFile 
83
-     * @param  string $localFile 
73
+	 */
74
+	public function getFile($remoteFile, $localFile)
75
+	{	
76
+		return \SSH::into($this->connectionName)->get($remoteFile, $localFile);    
77
+	}
78
+
79
+	/**
80
+	 * Places a file on a remote SSH/SFTP server
81
+	 * 
82
+	 * @param  string $remoteFile 
83
+	 * @param  string $localFile 
84 84
 	 * @return \Symfony\Component\Console\Output\OutputInterface
85
-     */
86
-    public function putFile($remoteFile, $localFile)
87
-    {
88
-    	return \SSH::into($this->connectionName)->put($localFile, $remoteFile);
89
-    }
90
-
91
-    /**
92
-     * Retrieves a listing from directory
93
-     * 
94
-     * @param  string 	$dir 
95
-     * @param  bool     $sorted 
96
-     * @param  string   $sortOrder 
85
+	 */
86
+	public function putFile($remoteFile, $localFile)
87
+	{
88
+		return \SSH::into($this->connectionName)->put($localFile, $remoteFile);
89
+	}
90
+
91
+	/**
92
+	 * Retrieves a listing from directory
93
+	 * 
94
+	 * @param  string 	$dir 
95
+	 * @param  bool     $sorted 
96
+	 * @param  string   $sortOrder 
97 97
 	 * @return array 	array of files and folders	
98
-     */
99
-    public function remoteList($dir, $sorted = true, $sortOrder = 'desc')
100
-    {
101
-    	$conn = $this->getConnection();
102
-    	$conn->chdir($dir);
103
-        $list = $conn->rawlist();
104
-
105
-        if ($sorted) {
106
-            $list = $this->sortList($list, $sortOrder);
107
-        }
98
+	 */
99
+	public function remoteList($dir, $sorted = true, $sortOrder = 'desc')
100
+	{
101
+		$conn = $this->getConnection();
102
+		$conn->chdir($dir);
103
+		$list = $conn->rawlist();
104
+
105
+		if ($sorted) {
106
+			$list = $this->sortList($list, $sortOrder);
107
+		}
108 108
     	
109
-    	return $list;    
110
-    }
111
-
112
-    /**
113
-     * Retrieves a listing from directory
114
-     * 
115
-     * @param  array    $list 
116
-     * @param  string   $sortOrder 
117
-     * @return array    sorted array of a folder
118
-     */
119
-    public function sortList($list, $sortOrder = 'desc')
120
-    {
121
-        usort($list, function($a, $b) { return $a['mtime'] - $b['mtime']; }); 
122
-
123
-        return $sortOrder == 'asc' ? $list : array_reverse($list);
124
-    }
125
-
126
-    /**
127
-     * Retrieves a listing from directory
128
-     * 
129
-     * @param  string   $remoteFileFrom 
130
-     * @param  string   $remoteFileTo 
131
-     * @return boolean  success
132
-     */
133
-    public function rename($remoteFileFrom, $remoteFileTo)
134
-    {
135
-        $conn = $this->getConnection();
136
-        //print $conn->getSFTPLog();
137
-        return $conn->rename($remoteFileFrom, $remoteFileTo);
138
-    }
139
-
140
-    /**
141
-     * Gets a Net_SFTP connection as Laravels SSH doesn't have all the functionality
142
-     * 
143
-     * @return Net_SFTP connection
144
-     */
145
-    protected function getConnection()
146
-    {
147
-    	return \SSH::into($this->connectionName)->getGateway()->getConnection();
148
-    }
149
-
150
-    /**
151
-     * Gets a Net_SFTP connection as Laravels SSH doesn't have all the functionality
152
-     * 
153
-     * @param  string $fileName 
154
-     * @return bool 	
155
-     */
156
-    protected function isValidExtension($fileName)
157
-    {
158
-    	return substr(strrchr($fileName, '.'), 1) === 'xml' || substr(strrchr($fileName, '.'), 1) === 'err';
159
-    }
109
+		return $list;    
110
+	}
111
+
112
+	/**
113
+	 * Retrieves a listing from directory
114
+	 * 
115
+	 * @param  array    $list 
116
+	 * @param  string   $sortOrder 
117
+	 * @return array    sorted array of a folder
118
+	 */
119
+	public function sortList($list, $sortOrder = 'desc')
120
+	{
121
+		usort($list, function($a, $b) { return $a['mtime'] - $b['mtime']; }); 
122
+
123
+		return $sortOrder == 'asc' ? $list : array_reverse($list);
124
+	}
125
+
126
+	/**
127
+	 * Retrieves a listing from directory
128
+	 * 
129
+	 * @param  string   $remoteFileFrom 
130
+	 * @param  string   $remoteFileTo 
131
+	 * @return boolean  success
132
+	 */
133
+	public function rename($remoteFileFrom, $remoteFileTo)
134
+	{
135
+		$conn = $this->getConnection();
136
+		//print $conn->getSFTPLog();
137
+		return $conn->rename($remoteFileFrom, $remoteFileTo);
138
+	}
139
+
140
+	/**
141
+	 * Gets a Net_SFTP connection as Laravels SSH doesn't have all the functionality
142
+	 * 
143
+	 * @return Net_SFTP connection
144
+	 */
145
+	protected function getConnection()
146
+	{
147
+		return \SSH::into($this->connectionName)->getGateway()->getConnection();
148
+	}
149
+
150
+	/**
151
+	 * Gets a Net_SFTP connection as Laravels SSH doesn't have all the functionality
152
+	 * 
153
+	 * @param  string $fileName 
154
+	 * @return bool 	
155
+	 */
156
+	protected function isValidExtension($fileName)
157
+	{
158
+		return substr(strrchr($fileName, '.'), 1) === 'xml' || substr(strrchr($fileName, '.'), 1) === 'err';
159
+	}
160 160
 }
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
app/Library/Xml.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
    	{    	
37 37
 		$xml = $xml ?: $this->xml;
38 38
 		//$array = json_decode(str_replace('{"0":" "}','null', json_encode(simplexml_load_string($xml),JSON_NUMERIC_CHECK)), true);
39
-		$array = json_decode(str_replace('{"0":" "}','null', json_encode(simplexml_load_string($xml))), true);
39
+		$array = json_decode(str_replace('{"0":" "}', 'null', json_encode(simplexml_load_string($xml))), true);
40 40
 		$this->filterEmptyArray($array);
41 41
 
42 42
 		return $array;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function replaceInNode($xml, $node, $find, $replace)
55 55
 	{       
56
-		return preg_replace_callback('@(<' . $node . '>)' . $find . '(</' . $node . '>)@s', function ($matches) use ($replace) {
56
+		return preg_replace_callback('@(<' . $node . '>)' . $find . '(</' . $node . '>)@s', function($matches) use ($replace) {
57 57
 			return str_replace(' ', $replace, $matches[0]);
58 58
 		}, $xml);
59 59
 	}
Please login to merge, or discard this patch.