use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Tools\TrashCan;
-use BookStack\Exceptions\ImageUploadException;
use BookStack\Exceptions\NotFoundException;
use BookStack\Facades\Activity;
use Exception;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
-use Illuminate\Http\UploadedFile;
use Illuminate\Support\Collection;
class BookshelfRepo
/**
* Convert an entity to a raw data array of input data.
+ *
* @return array<string, mixed>
*/
public function entityToInputData(Entity $entity): array
$this->trashCan->destroyEntity($chapter);
Activity::add(ActivityType::BOOK_CREATE_FROM_CHAPTER, $book);
+
return $book;
}
$shelf->books()->sync($shelfBookSyncData);
Activity::add(ActivityType::BOOKSHELF_CREATE_FROM_BOOK, $shelf);
+
return $shelf;
}
-}
\ No newline at end of file
+}
return response('', 204);
}
- protected function rules(): array {
+ protected function rules(): array
+ {
return [
'create' => [
'name' => ['required', 'string', 'max:255'],
if ($request->has('image_reset')) {
$validated['image'] = null;
- } else if (array_key_exists('image', $validated) && is_null($validated['image'])) {
+ } elseif (array_key_exists('image', $validated) && is_null($validated['image'])) {
unset($validated['image']);
}
if ($request->has('image_reset')) {
$validated['image'] = null;
- } else if (array_key_exists('image', $validated) && is_null($validated['image'])) {
+ } elseif (array_key_exists('image', $validated) && is_null($validated['image'])) {
unset($validated['image']);
}
return redirect($chapter->getUrl());
}
-
/**
* Convert the chapter to a book.
*/
// Ensure further updates without image do not clear cover image
$resp = $this->put($this->baseEndpoint . "/{$book->id}", [
- 'name' => 'My updated book again'
+ 'name' => 'My updated book again',
]);
$book->refresh();
// Ensure further updates without image do not clear cover image
$resp = $this->put($this->baseEndpoint . "/{$shelf->id}", [
- 'name' => 'My updated shelf again'
+ 'name' => 'My updated shelf again',
]);
$shelf->refresh();
class ConvertTest extends TestCase
{
-
public function test_chapter_edit_view_shows_convert_option()
{
/** @var Chapter $chapter */
$this->assertNotPermissionError($resp);
$resp->assertRedirect();
}
-
-}
\ No newline at end of file
+}
use BookStack\Entities\Models\Page;
use BookStack\Entities\Repos\BaseRepo;
use BookStack\Entities\Repos\BookRepo;
-use BookStack\Entities\Repos\BookshelfRepo;
use Illuminate\Support\Str;
use Tests\Uploads\UsesImages;
/** @var RolePermission $permission */
$permission = RolePermission::query()->where('name', '=', $permissionName)->firstOrFail();
- $roles = $user->roles()->whereHas('permissions', function($query) use ($permission) {
+ $roles = $user->roles()->whereHas('permissions', function ($query) use ($permission) {
$query->where('id', '=', $permission->id);
})->get();