Skip to content

Commit

Permalink
Merge pull request #263 from art-institute-of-chicago/feature/publish…
Browse files Browse the repository at this point in the history
…-selector-and-loan-objects

Add ability to publish selector and loan objects [MA-160]
  • Loading branch information
nikhiltri authored Mar 1, 2024
2 parents de4c88d + c4e31d7 commit aa7cb02
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/Http/Controllers/Api/Objects.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function __invoke()
$loanObjects = $selectorRepository
->getBaseModel()
->newQuery()
->visible()
->published()
->with(['object']) // This can only preload the LoanObjects
->whereExists($publishedStops)
->get()
Expand All @@ -36,6 +38,8 @@ public function __invoke()
$collectionObjectIds = $selectorRepository
->getBaseModel()
->newQuery()
->visible()
->published()
->whereExists($publishedStops)
->where('object_type', 'collectionObject')
->get()
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Twill/LoanObjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class LoanObjectController extends BaseController
protected function setUpController(): void
{
parent::setUpController();
$this->disablePublish();
$this->enableShowImage();
$this->setModuleName('loanObjects');
$this->setSearchColumns(['main_reference_number', 'title', 'artist_display']);
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Twill/SelectorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SelectorController extends BaseController
protected function setUpController(): void
{
parent::setUpController();
$this->disablePublish();
$this->setModuleName('selectors');
$this->setSearchColumns(['number']);
$this->setTitleColumnKey('number');
Expand Down
1 change: 1 addition & 0 deletions app/Models/LoanObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LoanObject extends AbstractModel
'longitude',
'main_reference_number',
'title',
'published',
];

protected $attributes = [
Expand Down
1 change: 1 addition & 0 deletions app/Models/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Selector extends Model
'number',
'object_id',
'object_type',
'published',
];

protected $casts = [
Expand Down
1 change: 1 addition & 0 deletions database/factories/LoanObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function definition(): array
'longitude' => fake()->randomFloat(nbMaxDecimals: 13, min: -180, max: 180),
'main_reference_number' => fake()->year() . fake()->randomNumber(nbDigits: 5),
'gallery_id' => Gallery::factory(),
'published' => true,
];
}
}
1 change: 1 addition & 0 deletions database/factories/SelectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public function definition(): array
{
return [
'number' => fake()->unique()->randomNumber(nbDigits: 3),
'published' => true,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Selector;

return new class extends Migration
{
public function up(): void
{
Schema::table('selectors', function (Blueprint $table) {
$table->boolean('published')->default(false);
});
Selector::query()->update(['published' => 1]);
}

public function down(): void
{
Schema::table('selectors', function (Blueprint $table) {
$table->dropColumn('published');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\LoanObject;

return new class extends Migration
{
public function up(): void
{
Schema::table('loan_objects', function (Blueprint $table) {
$table->boolean('published')->default(false);
});
LoanObject::query()->update(['published' => 1]);
}

public function down(): void
{
Schema::table('loan_objects', function (Blueprint $table) {
$table->dropColumn('published');
});
}
};

0 comments on commit aa7cb02

Please sign in to comment.