@@ -4,12 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | 6 | use Illuminate\Http\Response; |
| 7 | - |
|
| 8 | -use App\Http\Requests; |
|
| 9 | 7 | use App\Http\Controllers\Controller; |
| 10 | 8 | use Illuminate\Support\Facades\App; |
| 11 | -use Illuminate\Foundation\Application; |
|
| 12 | - |
|
| 13 | 9 | use POData\OperationContext\ServiceHost as ServiceHost; |
| 14 | 10 | use POData\SimpleDataService as DataService; |
| 15 | 11 | use POData\OperationContext\Web\Illuminate\IlluminateOperationContext as OperationContextAdapter; |
@@ -1,26 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace AlgoWeb\PODataLaravel\Models; |
| 3 | 3 | |
| 4 | -use Doctrine\DBAL\Exception\InvalidArgumentException; |
|
| 5 | 4 | use Illuminate\Support\Facades\Schema; |
| 6 | 5 | use Illuminate\Support\Facades\DB; |
| 7 | 6 | use Illuminate\Support\Facades\App; |
| 8 | -use Illuminate\Support\Str; |
|
| 9 | 7 | use Illuminate\Database\Eloquent\Relations\Relation; |
| 10 | - |
|
| 11 | 8 | use POData\Providers\Metadata\ResourceStreamInfo; |
| 12 | -use POData\Providers\Metadata\ResourceAssociationSetEnd; |
|
| 13 | -use POData\Providers\Metadata\ResourceAssociationSet; |
|
| 14 | -use POData\Common\NotImplementedException; |
|
| 15 | 9 | use POData\Providers\Metadata\Type\EdmPrimitiveType; |
| 16 | -use POData\Providers\Metadata\ResourceSet; |
|
| 17 | -use POData\Providers\Metadata\ResourcePropertyKind; |
|
| 18 | -use POData\Providers\Metadata\ResourceProperty; |
|
| 19 | -use POData\Providers\Metadata\ResourceTypeKind; |
|
| 20 | -use POData\Providers\Metadata\ResourceType; |
|
| 21 | -use POData\Common\InvalidOperationException; |
|
| 22 | -use POData\Providers\Metadata\IMetadataProvider; |
|
| 23 | -use POData\Providers\Metadata\SimpleMetadataProvider; |
|
| 24 | 10 | use Illuminate\Database\Eloquent\Model; |
| 25 | 11 | |
| 26 | 12 | trait MetadataTrait |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | }*/ |
| 61 | 61 | assert( |
| 62 | 62 | Schema::connection($connName)->hasTable($this->table), |
| 63 | - $this->table . ' table not present in current db, ' . $this->getConnectionName() |
|
| 63 | + $this->table.' table not present in current db, '.$this->getConnectionName() |
|
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | if ($key == $keyName) { |
| 121 | 121 | continue; |
| 122 | 122 | } |
| 123 | - if($secret['type'] == "blob"){ |
|
| 123 | + if ($secret['type'] == "blob") { |
|
| 124 | 124 | $complex->setMediaLinkEntry(true); |
| 125 | 125 | $streamInfo = new ResourceStreamInfo($key); |
| 126 | 126 | $complex->addNamedStream($streamInfo); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $reflection = new \ReflectionMethod($model, $method); |
| 220 | 220 | |
| 221 | 221 | $file = new \SplFileObject($reflection->getFileName()); |
| 222 | - $file->seek($reflection->getStartLine() - 1); |
|
| 222 | + $file->seek($reflection->getStartLine()-1); |
|
| 223 | 223 | $code = ''; |
| 224 | 224 | while ($file->key() < $reflection->getEndLine()) { |
| 225 | 225 | $code .= $file->current(); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | $code = trim(preg_replace('/\s\s+/', '', $code)); |
| 229 | 229 | $begin = strpos($code, 'function('); |
| 230 | - $code = substr($code, $begin, strrpos($code, '}') - $begin + 1); |
|
| 230 | + $code = substr($code, $begin, strrpos($code, '}')-$begin+1); |
|
| 231 | 231 | foreach (array( |
| 232 | 232 | 'hasMany', |
| 233 | 233 | 'hasManyThrough', |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | 'morphMany', |
| 240 | 240 | 'morphToMany' |
| 241 | 241 | ) as $relation) { |
| 242 | - $search = '$this->' . $relation . '('; |
|
| 242 | + $search = '$this->'.$relation.'('; |
|
| 243 | 243 | if ($pos = stripos($code, $search)) { |
| 244 | 244 | //Resolve the relation's model to a Relation object. |
| 245 | 245 | $relationObj = $model->$method(); |
| 246 | 246 | if ($relationObj instanceof Relation) { |
| 247 | - $relatedModel = '\\' . get_class($relationObj->getRelated()); |
|
| 247 | + $relatedModel = '\\'.get_class($relationObj->getRelated()); |
|
| 248 | 248 | $relations = ['hasManyThrough', 'belongsToMany', 'hasMany', 'morphMany', 'morphToMany']; |
| 249 | 249 | if (in_array($relation, $relations)) { |
| 250 | 250 | //Collection or array of models (because Collection is Arrayable) |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | $relationships["HasOne"][$method] = $relatedModel; |
| 270 | 270 | //$this->setProperty($method, $relatedModel, true, null); |
| 271 | 271 | } |
| 272 | - if (in_array($relation, ["morphMany","morphOne"])) { |
|
| 272 | + if (in_array($relation, ["morphMany", "morphOne"])) { |
|
| 273 | 273 | $relationships["KnownPolyMorphSide"][$method] = $relatedModel; |
| 274 | 274 | } |
| 275 | 275 | } |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use POData\UriProcessor\QueryProcessor\ExpressionParser\Expressions\PropertyAccessExpression; |
| 10 | 10 | use POData\UriProcessor\QueryProcessor\FunctionDescription; |
| 11 | 11 | use POData\Providers\Expression\IExpressionProvider; |
| 12 | -use Illuminate\Support\Str; |
|
| 13 | 12 | |
| 14 | 13 | class LaravelExpressionProvider implements IExpressionProvider |
| 15 | 14 | { |
@@ -240,17 +240,17 @@ discard block |
||
| 240 | 240 | case ODataConstants::DATETIME_COMPARE: |
| 241 | 241 | return "DATETIMECMP($params[0]; $params[1])"; |
| 242 | 242 | case ODataConstants::DATETIME_YEAR: |
| 243 | - return 'EXTRACT(YEAR from ' . $params[0] . ')'; |
|
| 243 | + return 'EXTRACT(YEAR from '.$params[0].')'; |
|
| 244 | 244 | case ODataConstants::DATETIME_MONTH: |
| 245 | - return 'EXTRACT(MONTH from ' . $params[0] . ')'; |
|
| 245 | + return 'EXTRACT(MONTH from '.$params[0].')'; |
|
| 246 | 246 | case ODataConstants::DATETIME_DAY: |
| 247 | - return 'EXTRACT(DAY from ' . $params[0] . ')'; |
|
| 247 | + return 'EXTRACT(DAY from '.$params[0].')'; |
|
| 248 | 248 | case ODataConstants::DATETIME_HOUR: |
| 249 | - return 'EXTRACT(HOUR from ' . $params[0] . ')'; |
|
| 249 | + return 'EXTRACT(HOUR from '.$params[0].')'; |
|
| 250 | 250 | case ODataConstants::DATETIME_MINUTE: |
| 251 | - return 'EXTRACT(MINUTE from ' . $params[0] . ')'; |
|
| 251 | + return 'EXTRACT(MINUTE from '.$params[0].')'; |
|
| 252 | 252 | case ODataConstants::DATETIME_SECOND: |
| 253 | - return 'EXTRACT(SECOND from ' . $params[0] . ')'; |
|
| 253 | + return 'EXTRACT(SECOND from '.$params[0].')'; |
|
| 254 | 254 | case ODataConstants::MATHFUN_ROUND: |
| 255 | 255 | return "ROUND($params[0])"; |
| 256 | 256 | case ODataConstants::MATHFUN_CEILING: |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | $str = explode(';', $left, 2); |
| 282 | 282 | $str[0] = str_replace('DATETIMECMP', '', $str[0]); |
| 283 | 283 | return self::OPEN_BRACKET |
| 284 | - .$str[0] . ' ' . $operator |
|
| 285 | - .' ' . $str[1] . self::CLOSE_BRACKET; |
|
| 284 | + .$str[0].' '.$operator |
|
| 285 | + .' '.$str[1].self::CLOSE_BRACKET; |
|
| 286 | 286 | } |
| 287 | 287 | //return self::OPEN_BRACKET . $left . ' ' . $operator . ' ' . $right . self::CLOSE_BRACKET; |
| 288 | 288 | return $this->getSql(); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | private function _prepareUnaryExpression($operator, $child) |
| 299 | 299 | { |
| 300 | - return $operator . self::OPEN_BRACKET . $child . self::CLOSE_BRACKET; |
|
| 300 | + return $operator.self::OPEN_BRACKET.$child.self::CLOSE_BRACKET; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | private function getSql() |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function boot() |
| 23 | 23 | { |
| 24 | 24 | self::$METANAMESPACE = env('ODataMetaNamespace', 'Data'); |
| 25 | - if(\App::runningInConsole() && count($_SERVER[ 'argv' ]) > 1 && $_SERVER[ 'argv' ][0] == "artisan"){ |
|
| 25 | + if (\App::runningInConsole() && count($_SERVER['argv']) > 1 && $_SERVER['argv'][0] == "artisan") { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - private static function setupRoute(){ |
|
| 86 | + private static function setupRoute() { |
|
| 87 | 87 | $valueArray = []; |
| 88 | 88 | |
| 89 | 89 | Route::any('odata.svc/{section}', 'AlgoWeb\PODataLaravel\Controllers\ODataController@index') ->where(['section' => '.*']); |
| 90 | 90 | Route::any('odata.svc', 'AlgoWeb\PODataLaravel\Controllers\ODataController@index'); |
| 91 | 91 | |
| 92 | - Route::get('/', function () use ($valueArray) { |
|
| 92 | + Route::get('/', function() use ($valueArray) { |
|
| 93 | 93 | $array = array( |
| 94 | 94 | '@odata.context' => Config::get('app.url').'/$metadata', |
| 95 | 95 | 'value' => $valueArray |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function register() |
| 107 | 107 | { |
| 108 | - $this->app->singleton('metadata', function ($app) { |
|
| 108 | + $this->app->singleton('metadata', function($app) { |
|
| 109 | 109 | return new SimpleMetadataProvider('Data', self::$METANAMESPACE); |
| 110 | 110 | }); |
| 111 | 111 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function register() |
| 26 | 26 | { |
| 27 | - $this->app->singleton('odataquery', function ($app) { |
|
| 27 | + $this->app->singleton('odataquery', function($app) { |
|
| 28 | 28 | return new LaravelQuery(); |
| 29 | 29 | }); |
| 30 | 30 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | public function __construct() |
| 25 | 25 | { |
| 26 | 26 | /* MySQLExpressionProvider();*/ |
| 27 | - $this->expression = new LaravelExpressionProvider(DB::table('dummy'));//PHPExpressionProvider('expression'); |
|
| 27 | + $this->expression = new LaravelExpressionProvider(DB::table('dummy')); //PHPExpressionProvider('expression'); |
|
| 28 | 28 | $this->queryProviderClassName = get_class($this); |
| 29 | 29 | } |
| 30 | 30 | |