Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Fix blueprint error when publishing Eloquent Driver migrations #320

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Routing/RoutingModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Statamic\Data\ContainsSupplementalData;
use Statamic\Data\HasAugmentedData;

class RoutingModel implements Responsable, Augmentable
class RoutingModel implements Augmentable, Responsable
{
use ContainsSupplementalData, HasAugmentedData;

Expand Down
15 changes: 12 additions & 3 deletions src/Runway.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ public static function discoverResources(): self
if (! in_array(Traits\HasRunwayResource::class, class_uses_recursive($model))) {
throw new \Exception(__('The HasRunwayResource trait is missing from the [:model] model.', ['model' => $model]));
}

if (! isset($config['blueprint'])) {
throw new \Exception(__('The [:model] model is missing a blueprint.', ['model' => $model]));
}

if (is_string($config['blueprint'])) {
$blueprint = Blueprint::find($config['blueprint']);
try {
$blueprint = Blueprint::find($config['blueprint']);
} catch (\Exception $e) {
// If we're running in a console & the blueprint doesn't exist, let's ignore the resource.
// https://github.com/duncanmcclean/runway/pull/320
if (app()->runningInConsole()) {
return;
}

throw $e;
}
}

if (is_array($config['blueprint'])) {
Expand Down Expand Up @@ -74,7 +83,7 @@ public static function findResource(string $resourceHandle): ?Resource

public static function findResourceByModel(object $model): ?Resource
{
$resource = collect(static::$resources)->filter(fn (Resource $resource) => $resource->model()::class === $model::class)->first();
$resource = collect(static::$resources)->filter(fn (Resource $resource) => $model::class === $resource->model()::class)->first();

if (! $resource) {
throw new ResourceNotFound($model::class);
Expand Down
4 changes: 2 additions & 2 deletions src/Search/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use Statamic\Facades\Site;
use Statamic\Search\Result as ResultInstance;

class Searchable implements Contract, ContainsQueryableValues, Augmentable
class Searchable implements Augmentable, ContainsQueryableValues, Contract
{
use HasAugmentedInstance, ContainsSupplementalData;
use ContainsSupplementalData, HasAugmentedInstance;

protected $model;

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasRunwayResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

trait HasRunwayResource
{
use HasAugmentedInstance, FluentlyGetsAndSets;
use FluentlyGetsAndSets, HasAugmentedInstance;
use ResolvesValues {
resolveGqlValue as traitResolveGqlValue;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function authorFactory(int $count = 1, array $attributes = [])

class Post extends Model
{
use RunwayRoutes, HasRunwayResource;
use HasRunwayResource, RunwayRoutes;

protected $fillable = [
'title', 'slug', 'body', 'values', 'author_id', 'sort_order',
Expand Down
Loading