deactivate bookcases

This commit is contained in:
HolgerHatGarKeineNode
2023-02-16 21:21:45 +01:00
parent ab56630227
commit d90af476bc
7 changed files with 16 additions and 8 deletions

View File

@@ -32,7 +32,7 @@ class SyncOpenBooks extends Command
try {
foreach ($response->json()['cases'] as $case) {
BookCase::withoutGlobalScopes()->updateOrCreate(
BookCase::updateOrCreate(
[
'id' => $case['id'],
],

View File

@@ -31,7 +31,7 @@ class BookCaseTable extends Component
'icon_size' => [42, 42],
])
->toArray(),
'bookCases' => BookCase::get(),
'bookCases' => BookCase::query()->active()->get(),
'countries' => Country::query()
->select(['code', 'name'])
->get(),

View File

@@ -13,8 +13,10 @@ class Heatmap extends Component
public function render()
{
$data = BookCase::query()
->active()
->whereHas('orangePills')
->get()->map(fn($bookCase) => [
->get()
->map(fn($bookCase) => [
'lat' => $bookCase->latitude,
'lng' => $bookCase->longitude,
]);

View File

@@ -17,6 +17,7 @@ class WorldMap extends Component
'mapData' => BookCase::query()
->select(['id', 'latitude', 'longitude'])
->withCount('orangePills')
->active()
->get()
->map(fn($bookCase) => [
'lat' => $bookCase->latitude,

View File

@@ -123,6 +123,7 @@ class BookCaseTable extends DataTableComponent
public function builder(): Builder
{
return BookCase::query()
->active()
->with([
'orangePills',
])

View File

@@ -113,7 +113,7 @@ class CityTable extends DataTableComponent
{
$city = City::query()
->find($id);
$query = BookCase::radius($city->latitude, $city->longitude, 25);
$query = BookCase::active()->radius($city->latitude, $city->longitude, 25);
$ids = $query->pluck('id');
if ($ids->isEmpty()) {
$this->notification()

View File

@@ -41,7 +41,6 @@ class BookCase extends Model implements HasMedia
protected static function booted()
{
static::addGlobalScope(new ActiveBookCases);
static::creating(function ($model) {
if (!$model->created_by) {
$model->created_by = auth()->id();
@@ -49,6 +48,11 @@ class BookCase extends Model implements HasMedia
});
}
public function scopeActive($query)
{
return $query->where('deactivated', false);
}
public function registerMediaConversions(Media $media = null): void
{
$this