2018-11-01 08:55:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
2022-03-19 13:54:32 +00:00
|
|
|
use App\Application;
|
|
|
|
use App\Item;
|
|
|
|
use App\SupportedApps;
|
2018-11-01 08:55:21 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
2022-11-21 23:05:57 +00:00
|
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
2018-11-01 08:55:21 +00:00
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
2022-03-19 13:54:32 +00:00
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
2022-11-18 15:12:52 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2022-03-14 15:56:36 +00:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2018-11-01 08:55:21 +00:00
|
|
|
|
2022-11-21 23:05:57 +00:00
|
|
|
class ProcessApps implements ShouldQueue, ShouldBeUnique
|
2018-11-01 08:55:21 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2022-11-18 15:12:52 +00:00
|
|
|
Log::debug('Process Apps dispatched');
|
2022-03-16 15:49:44 +00:00
|
|
|
$localapps = Application::whereNull('class')->get();
|
2022-03-14 15:56:36 +00:00
|
|
|
$json = SupportedApps::getList()->getBody();
|
|
|
|
|
|
|
|
Storage::disk('local')->put('supportedapps.json', $json);
|
|
|
|
|
2022-03-19 13:54:32 +00:00
|
|
|
foreach ($localapps as $app) {
|
2022-03-16 15:49:44 +00:00
|
|
|
$app->class = $app->class();
|
|
|
|
$app->save();
|
|
|
|
}
|
2018-11-01 08:55:21 +00:00
|
|
|
|
2022-03-17 13:41:50 +00:00
|
|
|
$items = Item::whereNotNull('class')->get();
|
2022-03-19 13:54:32 +00:00
|
|
|
foreach ($items as $item) {
|
|
|
|
if (! file_exists(app_path('SupportedApps/'.Item::nameFromClass($item->class)))) {
|
2022-03-17 13:41:50 +00:00
|
|
|
$app = Application::where('class', $item->class)->first();
|
2022-04-02 14:19:55 +00:00
|
|
|
if ($app) {
|
|
|
|
Application::getApp($app->appid);
|
|
|
|
}
|
2022-03-17 13:41:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-01 08:55:21 +00:00
|
|
|
}
|
|
|
|
}
|