Heimdall/app/Jobs/ProcessApps.php

57 lines
1.3 KiB
PHP
Raw Normal View History

2018-11-01 08:55:21 +00:00
<?php
namespace App\Jobs;
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;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
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();
$json = SupportedApps::getList()->getBody();
Storage::disk('local')->put('supportedapps.json', $json);
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();
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
}
}