mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
deactivate bookcases
This commit is contained in:
@@ -32,7 +32,7 @@ class SyncOpenBooks extends Command
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
foreach ($response->json()['cases'] as $case) {
|
foreach ($response->json()['cases'] as $case) {
|
||||||
BookCase::withoutGlobalScopes()->updateOrCreate(
|
BookCase::updateOrCreate(
|
||||||
[
|
[
|
||||||
'id' => $case['id'],
|
'id' => $case['id'],
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class BookCaseTable extends Component
|
|||||||
'icon_size' => [42, 42],
|
'icon_size' => [42, 42],
|
||||||
])
|
])
|
||||||
->toArray(),
|
->toArray(),
|
||||||
'bookCases' => BookCase::get(),
|
'bookCases' => BookCase::query()->active()->get(),
|
||||||
'countries' => Country::query()
|
'countries' => Country::query()
|
||||||
->select(['code', 'name'])
|
->select(['code', 'name'])
|
||||||
->get(),
|
->get(),
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ class Heatmap extends Component
|
|||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$data = BookCase::query()
|
$data = BookCase::query()
|
||||||
|
->active()
|
||||||
->whereHas('orangePills')
|
->whereHas('orangePills')
|
||||||
->get()->map(fn($bookCase) => [
|
->get()
|
||||||
|
->map(fn($bookCase) => [
|
||||||
'lat' => $bookCase->latitude,
|
'lat' => $bookCase->latitude,
|
||||||
'lng' => $bookCase->longitude,
|
'lng' => $bookCase->longitude,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class WorldMap extends Component
|
|||||||
'mapData' => BookCase::query()
|
'mapData' => BookCase::query()
|
||||||
->select(['id', 'latitude', 'longitude'])
|
->select(['id', 'latitude', 'longitude'])
|
||||||
->withCount('orangePills')
|
->withCount('orangePills')
|
||||||
|
->active()
|
||||||
->get()
|
->get()
|
||||||
->map(fn($bookCase) => [
|
->map(fn($bookCase) => [
|
||||||
'lat' => $bookCase->latitude,
|
'lat' => $bookCase->latitude,
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ class BookCaseTable extends DataTableComponent
|
|||||||
public function builder(): Builder
|
public function builder(): Builder
|
||||||
{
|
{
|
||||||
return BookCase::query()
|
return BookCase::query()
|
||||||
|
->active()
|
||||||
->with([
|
->with([
|
||||||
'orangePills',
|
'orangePills',
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class CityTable extends DataTableComponent
|
|||||||
{
|
{
|
||||||
$city = City::query()
|
$city = City::query()
|
||||||
->find($id);
|
->find($id);
|
||||||
$query = BookCase::radius($city->latitude, $city->longitude, 25);
|
$query = BookCase::active()->radius($city->latitude, $city->longitude, 25);
|
||||||
$ids = $query->pluck('id');
|
$ids = $query->pluck('id');
|
||||||
if ($ids->isEmpty()) {
|
if ($ids->isEmpty()) {
|
||||||
$this->notification()
|
$this->notification()
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class BookCase extends Model implements HasMedia
|
|||||||
|
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::addGlobalScope(new ActiveBookCases);
|
|
||||||
static::creating(function ($model) {
|
static::creating(function ($model) {
|
||||||
if (!$model->created_by) {
|
if (!$model->created_by) {
|
||||||
$model->created_by = auth()->id();
|
$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
|
public function registerMediaConversions(Media $media = null): void
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
|
|||||||
Reference in New Issue
Block a user