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;
|
|
|
|
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-03-14 15:56:36 +00:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2018-11-01 08:55:21 +00:00
|
|
|
|
|
|
|
class ProcessApps implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
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();
|
|
|
|
Application::getApp($app->appid);
|
|
|
|
}
|
|
|
|
}
|
2018-11-01 08:55:21 +00:00
|
|
|
}
|
|
|
|
}
|