1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

ZIP Import: Added model+migration, and reader class

This commit is contained in:
Dan Brown
2024-11-02 17:17:34 +00:00
parent 259aa829d4
commit 74fce9640e
8 changed files with 234 additions and 35 deletions

41
app/Exports/Import.php Normal file
View File

@ -0,0 +1,41 @@
<?php
namespace BookStack\Exports;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $path
* @property string $name
* @property int $size - ZIP size in bytes
* @property int $book_count
* @property int $chapter_count
* @property int $page_count
* @property int $created_by
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class Import extends Model
{
use HasFactory;
public const TYPE_BOOK = 'book';
public const TYPE_CHAPTER = 'chapter';
public const TYPE_PAGE = 'page';
/**
* Get the type (model) that this import is intended to be.
*/
public function getType(): string
{
if ($this->book_count === 1) {
return self::TYPE_BOOK;
} elseif ($this->chapter_count === 1) {
return self::TYPE_CHAPTER;
}
return self::TYPE_PAGE;
}
}