Skip to content

Commit 3201bc9

Browse files
committed
Merge branch 'feature/async' into async-with-cn
2 parents c11fc89 + 93f51a0 commit 3201bc9

File tree

8 files changed

+62
-76
lines changed

8 files changed

+62
-76
lines changed

src/LaravelJsonApi.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class LaravelJsonApi
1010
*
1111
* @var bool
1212
*/
13-
public static $runMigrations = true;
13+
public static $runMigrations = false;
1414

1515
/**
1616
* Indicates if listeners will be bound to the Laravel queue events.
@@ -22,9 +22,9 @@ class LaravelJsonApi
2222
/**
2323
* @return LaravelJsonApi
2424
*/
25-
public static function ignoreMigrations(): self
25+
public static function runMigrations(): self
2626
{
27-
static::$runMigrations = false;
27+
static::$runMigrations = true;
2828

2929
return new self();
3030
}

src/Resources/QueueJobs/Schema.php renamed to src/Queue/ClientJobSchema.php

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,25 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace CloudCreativity\LaravelJsonApi\Resources\QueueJobs;
18+
namespace CloudCreativity\LaravelJsonApi\Queue;
1919

20-
use CloudCreativity\LaravelJsonApi\Queue\ClientJob;
21-
use DateTime;
2220
use Neomerx\JsonApi\Schema\SchemaProvider;
2321

24-
class Schema extends SchemaProvider
22+
abstract class ClientJobSchema extends SchemaProvider
2523
{
2624

2725
/**
2826
* @var string
2927
*/
3028
protected $resourceType = 'queue-jobs';
3129

32-
/**
33-
* @var string
34-
*/
35-
protected $dateFormat = DateTime::ATOM;
36-
3730
/**
3831
* @param ClientJob $resource
3932
* @return string
4033
*/
4134
public function getId($resource)
4235
{
43-
return $resource->getRouteKey();
44-
}
45-
46-
/**
47-
* @param ClientJob $resource
48-
* @return array
49-
*/
50-
public function getAttributes($resource)
51-
{
52-
/** @var DateTime|null $completedAt */
53-
$completedAt = $resource->completed_at;
54-
/** @var DateTime|null $timeoutAt */
55-
$timeoutAt = $resource->timeout_at;
56-
57-
return [
58-
'attempts' => $resource->attempts,
59-
'created-at' => $resource->created_at->format($this->dateFormat),
60-
'completed-at' => $completedAt ? $completedAt->format($this->dateFormat) : null,
61-
'failed' => $resource->failed,
62-
'resource-type' => $resource->resource_type,
63-
'timeout' => $resource->timeout,
64-
'timeout-at' => $timeoutAt ? $timeoutAt->format($this->dateFormat) : null,
65-
'tries' => $resource->tries,
66-
'updated-at' => $resource->updated_at->format($this->dateFormat),
67-
];
36+
return (string) $resource->getRouteKey();
6837
}
6938

7039
/**

src/Resources/ResourceProvider.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/Resources/QueueJobs/Adapter.php renamed to tests/dummy/app/JsonApi/QueueJobs/Adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace CloudCreativity\LaravelJsonApi\Resources\QueueJobs;
18+
namespace DummyApp\JsonApi\QueueJobs;
1919

2020
use CloudCreativity\LaravelJsonApi\Eloquent\AbstractAdapter;
2121
use CloudCreativity\LaravelJsonApi\Queue\ClientJob;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright 2018 Cloud Creativity Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
namespace DummyApp\JsonApi\QueueJobs;
19+
20+
use Carbon\Carbon;
21+
use CloudCreativity\LaravelJsonApi\Queue\ClientJob;
22+
use CloudCreativity\LaravelJsonApi\Queue\ClientJobSchema;
23+
24+
class Schema extends ClientJobSchema
25+
{
26+
27+
/**
28+
* @param ClientJob $resource
29+
* @return array
30+
*/
31+
public function getAttributes($resource)
32+
{
33+
/** @var Carbon|null $completedAt */
34+
$completedAt = $resource->completed_at;
35+
/** @var Carbon|null $timeoutAt */
36+
$timeoutAt = $resource->timeout_at;
37+
38+
return [
39+
'attempts' => $resource->attempts,
40+
'completed-at' => $completedAt ? $completedAt->toAtomString() : null,
41+
'created-at' => $resource->created_at->toAtomString(),
42+
'failed' => $resource->failed,
43+
'resource-type' => $resource->resource_type,
44+
'timeout' => $resource->timeout,
45+
'timeout-at' => $timeoutAt ? $timeoutAt->toAtomString() : null,
46+
'tries' => $resource->tries,
47+
'updated-at' => $resource->updated_at->toAtomString(),
48+
];
49+
}
50+
51+
}

src/Resources/QueueJobs/Validators.php renamed to tests/dummy/app/JsonApi/QueueJobs/Validators.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
namespace CloudCreativity\LaravelJsonApi\Resources\QueueJobs;
18+
namespace DummyApp\JsonApi\QueueJobs;
1919

2020
use CloudCreativity\LaravelJsonApi\Exceptions\RuntimeException;
2121
use CloudCreativity\LaravelJsonApi\Validation\AbstractValidators;

tests/dummy/app/Providers/AppServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace DummyApp\Providers;
1919

2020
use CloudCreativity\LaravelJsonApi\Facades\JsonApi;
21+
use CloudCreativity\LaravelJsonApi\LaravelJsonApi;
2122
use DummyApp\Entities\SiteRepository;
2223
use DummyApp\Policies\PostPolicy;
2324
use DummyApp\Policies\UserPolicy;
@@ -60,6 +61,7 @@ public function boot()
6061
*/
6162
public function register()
6263
{
64+
LaravelJsonApi::runMigrations();
6365
$this->app->singleton(SiteRepository::class);
6466
}
6567

tests/dummy/config/json-api-v1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'downloads' => \DummyApp\Download::class,
6060
'phones' => \DummyApp\Phone::class,
6161
'posts' => \DummyApp\Post::class,
62+
'queue-jobs' => \CloudCreativity\LaravelJsonApi\Queue\ClientJob::class,
6263
'sites' => \DummyApp\Entities\Site::class,
6364
'tags' => \DummyApp\Tag::class,
6465
'users' => \DummyApp\User::class,
@@ -152,7 +153,6 @@
152153
|
153154
*/
154155
'providers' => [
155-
\CloudCreativity\LaravelJsonApi\Resources\ResourceProvider::class,
156156
\DummyPackage\ResourceProvider::class,
157157
],
158158

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy