Merge pull request #1248 from openclassify/dia

#4984 [evdepismis-theme] yapılacaklar
This commit is contained in:
Muammer Top 2021-12-13 14:21:39 +03:00 committed by GitHub
commit 1f4cbca655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use Visiosoft\AdvsModule\Adv\AdvRepository;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
use Visiosoft\AdvsModule\Console\Commands\DeleteNonExistingCoverPhotos;
use Visiosoft\AdvsModule\Http\Middleware\redirectDiffrentLang;
use Visiosoft\AdvsModule\Http\Middleware\SetLang;
use Visiosoft\AdvsModule\Listener\AddAdvsSettingsScript;
@ -42,6 +43,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
AdvsModulePlugin::class,
];
protected $commands = [
DeleteNonExistingCoverPhotos::class
];
protected $routes = [
// Admin AdvsController
'admin/advs' => [

View File

@ -0,0 +1,38 @@
<?php namespace Visiosoft\AdvsModule\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class DeleteNonExistingCoverPhotos extends Command
{
protected $signature = 'classifieds:refresh-cover-images';
protected $description = 'Nullify non existing cover images.';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$classifieds = DB::table('advs_advs')
->whereNotNull('cover_photo')
->get();
$nullableClassifieds = array();
foreach ($classifieds as $classified) {
$name = pathinfo($classified->cover_photo);
if (!file_exists(storage_path("streams/default/files-module/local/images/{$name['basename']}"))) {
$nullableClassifieds[] = $classified->id;
}
}
DB::table('advs_advs')
->whereIn('id', $nullableClassifieds)
->update(['cover_photo' => null]);
$this->info('Classifieds refreshed!');
}
}