Skip to content

Commit

Permalink
Merge branch 'statamic-5' into fix/add-arguments-to-import-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Apr 12, 2024
2 parents 1a2388e + 700cf80 commit 3a62440
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public function up()
$table->string('site')->index();
$table->unsignedBigInteger('origin_id')->nullable()->index();
$table->boolean('published')->default(true);
$table->string('status');
$table->string('slug')->nullable();
$table->string('uri')->nullable()->index();
$table->string('date')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public function up()
$table->string('site')->index();
$table->uuid('origin_id')->nullable()->index();
$table->boolean('published')->default(true);
$table->string('status');
$table->string('slug')->nullable();
$table->string('uri')->nullable()->index();
$table->string('date')->nullable();
Expand Down
21 changes: 21 additions & 0 deletions database/migrations/updates/drop_status_on_entries.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Statamic\Eloquent\Database\BaseMigration as Migration;

return new class extends Migration {
public function up()
{
Schema::table($this->prefix('entries'), function (Blueprint $table) {
$table->dropColumn('status');
});
}

public function down()
{
Schema::table($this->prefix('entries'), function (Blueprint $table) {
$table->string('status')->nullable();
});
}
};
19 changes: 9 additions & 10 deletions src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,17 @@ public static function makeModelFromContract(EntryContract $source)
}

$attributes = [
'origin_id' => $origin?->id(),
'site' => $source->locale(),
'slug' => $source->slug(),
'uri' => $source->uri(),
'date' => $date,
'origin_id' => $origin?->id(),
'site' => $source->locale(),
'slug' => $source->slug(),
'uri' => $source->uri(),
'date' => $date,
'collection' => $source->collectionHandle(),
'blueprint' => $source->blueprint ?? $source->blueprint()->handle(),
'data' => $data->except(EntryQueryBuilder::COLUMNS),
'published' => $source->published(),
'status' => $source->status(),
'blueprint' => $source->blueprint ?? $source->blueprint()->handle(),
'data' => $data->except(EntryQueryBuilder::COLUMNS),
'published' => $source->published(),
'updated_at' => $source->lastModified(),
'order' => $source->order(),
'order' => $source->order(),
];

if ($id = $source->id()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Entries/EntryQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EntryQueryBuilder extends EloquentQueryBuilder implements QueryBuilder
private $selectedQueryColumns;

const COLUMNS = [
'id', 'site', 'origin_id', 'published', 'status', 'slug', 'uri',
'id', 'site', 'origin_id', 'published', 'slug', 'uri',
'date', 'collection', 'created_at', 'updated_at', 'order', 'blueprint',
];

Expand Down
2 changes: 1 addition & 1 deletion src/Revisions/RevisionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RevisionRepository extends StacheRepository
{
public function make(): RevisionContract
{
return app('statamic.eloquent.revisions.model');
return new (app('statamic.eloquent.revisions.model'));
}

public function whereKey($key)
Expand Down
1 change: 1 addition & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ServiceProvider extends AddonServiceProvider
\Statamic\Eloquent\Updates\SplitGlobalsFromVariables::class,
\Statamic\Eloquent\Updates\AddIdToAttributesInRevisionsTable::class,
\Statamic\Eloquent\Updates\RelateFormSubmissionsByHandle::class,
\Statamic\Eloquent\Updates\DropStatusOnEntries::class,
];

protected $listen = [
Expand Down
24 changes: 24 additions & 0 deletions src/Updates/DropStatusOnEntries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Statamic\Eloquent\Updates;

use Statamic\UpdateScripts\UpdateScript;

class DropStatusOnEntries extends UpdateScript
{
public function shouldUpdate($newVersion, $oldVersion)
{
return $this->isUpdatingTo('4.0.0');
}

public function update()
{
$source = __DIR__.'/../../database/migrations/updates/drop_status_on_entries.php.stub';
$dest = database_path('migrations/'.date('Y_m_d_His').'_drop_status_on_entries.php');

$this->files->copy($source, $dest);

$this->console()->info('Migrations created');
$this->console()->comment('Remember to run `php artisan migrate` to apply it to your database.');
}
}
15 changes: 7 additions & 8 deletions tests/Entries/EntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ public function it_saves_to_entry_model()
'data' => [
'foo' => 'bar',
],
'site' => 'en',
'uri' => '/blog/the-slug',
'date' => null,
'site' => 'en',
'uri' => '/blog/the-slug',
'date' => null,
'collection' => 'blog',
'blueprint' => 'blog',
'published' => false,
'status' => 'draft',
'origin_id' => null,
'order' => null,
'blueprint' => 'blog',
'published' => false,
'origin_id' => null,
'order' => null,
]);

$collection = Collection::make('blog')->title('blog')->routes([
Expand Down

0 comments on commit 3a62440

Please sign in to comment.