use App\Fluidbook\Compiler\Compiler;
use App\Http\Controllers\Admin\Operations\FluidbookPreviewOperation;
use App\Http\Middleware\CheckIfAdmin;
+use App\Models\FluidbookHealthIssues;
use App\Models\FluidbookPublication;
use App\Models\FluidbookTheme;
use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
$relayPath = $dest . '/' . $path;
if (!file_exists($relayPath)) {
- throw new \Exception($relayPath . ' not found');
+ FluidbookHealthIssues::addIssue($fluidbook->id, FluidbookHealthIssues::TYPE_MISSING_FILE, $path);
+ abort(404, __('Ce fichier n\'existe pas'));
}
return XSendFileController::sendfile($relayPath);
}
--- /dev/null
+<?php
+
+namespace App\Models;
+
+use App\Fields\FluidbookID;
+use App\Models\Base\ToolboxModel;
+use Cubist\Backpack\Magic\Fields\Integer;
+use Cubist\Backpack\Magic\Fields\Text;
+
+class FluidbookHealthIssues extends ToolboxModel
+{
+ const TYPE_MISSING_FILE = 1;
+
+ protected $table = 'fluidbook_health_issue';
+ protected $_options = ['name' => 'fluidbook-health',
+ 'singular' => 'problème',
+ 'plural' => 'problèmes'];
+
+ protected static $_permissionBase = 'fluidbook-health-issue';
+
+ public function setFields()
+ {
+ parent::setFields();
+
+ $this->addField('fluidbook', FluidbookID::class, __('Fluidbook'));
+ $this->addField('type', Integer::class, __('Type'));
+ $this->addField('data', Text::class, __('Détails'));
+ }
+
+ public static function addIssue($fluidbookId, $type, $data = '')
+ {
+
+ $issue = self::withoutGlobalScopes()->where('fluidbook', $fluidbookId)->where('type', $type)->where('data', $data)->first();
+ if (!$issue) {
+ $issue = new self(['fluidbook' => $fluidbookId, 'type' => $type, 'data' => $data]);
+ }
+ $issue->updateTimestamps();
+ $issue->save();
+ }
+}