mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-23 18:56:08 +00:00
Fixed issue with using old non-existing reference in controller
Also done a little code cleanup.
This commit is contained in:
parent
917d7428d6
commit
3d5899d28c
@ -102,8 +102,8 @@ class AttachmentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, string $attachmentId)
|
public function update(Request $request, string $attachmentId)
|
||||||
{
|
{
|
||||||
$attachment = $this->attachment->newQuery()->findOrFail($attachmentId);
|
/** @var Attachment $attachment */
|
||||||
|
$attachment = Attachment::query()->findOrFail($attachmentId);
|
||||||
try {
|
try {
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'attachment_edit_name' => 'required|string|min:1|max:255',
|
'attachment_edit_name' => 'required|string|min:1|max:255',
|
||||||
@ -158,7 +158,7 @@ class AttachmentController extends Controller
|
|||||||
|
|
||||||
$attachmentName = $request->get('attachment_link_name');
|
$attachmentName = $request->get('attachment_link_name');
|
||||||
$link = $request->get('attachment_link_url');
|
$link = $request->get('attachment_link_url');
|
||||||
$attachment = $this->attachmentService->saveNewFromLink($attachmentName, $link, intval($pageId));
|
$this->attachmentService->saveNewFromLink($attachmentName, $link, intval($pageId));
|
||||||
|
|
||||||
return view('attachments.manager-link-form', [
|
return view('attachments.manager-link-form', [
|
||||||
'pageId' => $pageId,
|
'pageId' => $pageId,
|
||||||
@ -231,6 +231,7 @@ class AttachmentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(string $attachmentId)
|
public function delete(string $attachmentId)
|
||||||
{
|
{
|
||||||
|
/** @var Attachment $attachment */
|
||||||
$attachment = Attachment::query()->findOrFail($attachmentId);
|
$attachment = Attachment::query()->findOrFail($attachmentId);
|
||||||
$this->checkOwnablePermission('attachment-delete', $attachment);
|
$this->checkOwnablePermission('attachment-delete', $attachment);
|
||||||
$this->attachmentService->deleteFile($attachment);
|
$this->attachmentService->deleteFile($attachment);
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
use BookStack\Entities\Models\Page;
|
use BookStack\Entities\Models\Page;
|
||||||
use BookStack\Model;
|
use BookStack\Model;
|
||||||
use BookStack\Traits\HasCreatorAndUpdater;
|
use BookStack\Traits\HasCreatorAndUpdater;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int id
|
* @property int id
|
||||||
* @property string name
|
* @property string name
|
||||||
* @property string path
|
* @property string path
|
||||||
* @property string extension
|
* @property string extension
|
||||||
|
* @property ?Page page
|
||||||
* @property bool external
|
* @property bool external
|
||||||
*/
|
*/
|
||||||
class Attachment extends Model
|
class Attachment extends Model
|
||||||
@ -31,9 +33,8 @@ class Attachment extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the page this file was uploaded to.
|
* Get the page this file was uploaded to.
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
||||||
*/
|
*/
|
||||||
public function page()
|
public function page(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Page::class, 'uploaded_to');
|
return $this->belongsTo(Page::class, 'uploaded_to');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user