83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
namespace App\Http\Controllers\Admin\Contents;
|
|
|
|
use App\CMS\Contracts\Repositories\Content as ContentContract;
|
|
use App\Cms\Handlers\Interactions\Interaction;
|
|
use App\CMS\Interactions\Admin\Content\ChangeStatus;
|
|
use App\CMS\Interactions\Admin\Content\DeletePage;
|
|
use App\CMS\Interactions\Admin\Content\SetHomepage;
|
|
use App\Http\Controllers\Admin\Controller;
|
|
use App\Models\Content\Content;
|
|
use App\Models\Content\ContentHistory;
|
|
|
|
class ContentActions extends Controller
|
|
{
|
|
/**
|
|
* @var ContentContract
|
|
*/
|
|
private $content;
|
|
|
|
public function __construct(ContentContract $content)
|
|
{
|
|
$this->content = $content;
|
|
}
|
|
|
|
/**
|
|
* Method for changing page status
|
|
* This method is called in static page overview from quick actions. It checks if status is valid, if page exists
|
|
* and updates status.
|
|
*
|
|
* @param Content $page
|
|
* @param $status
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function changeStatus(Content $page, $status)
|
|
{
|
|
Interaction::handle(ChangeStatus::class, ['status' => $status], $page);
|
|
|
|
// redirect back to overview with info for user
|
|
return redirect()
|
|
->route('content.overview')
|
|
->with('success', trans('admin/contents.statusChanged'));
|
|
}
|
|
|
|
/**
|
|
* Delete page
|
|
*
|
|
* @param Content $page
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function delete(Content $page)
|
|
{
|
|
Interaction::handle(DeletePage::class, [], $page);
|
|
|
|
// redirect back to overview with info for user
|
|
return redirect()
|
|
->route('content.overview')
|
|
->with('success', trans('admin/contents.pageDeleted', [
|
|
'name' => $page->title
|
|
]));
|
|
}
|
|
|
|
/**
|
|
* Sets page as homepage
|
|
*
|
|
* @param Content $page
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function setHomepage(Content $page)
|
|
{
|
|
Interaction::handle(SetHomepage::class, [], $page);
|
|
|
|
// redirect back to overview with info for user
|
|
return redirect()
|
|
->back()
|
|
->with('success', trans('admin/contents.homepageSetup', [
|
|
'name' => $page->title,
|
|
'url' => $page->url
|
|
]));
|
|
}
|
|
} |