REFACTORING #1880 @1h: move content actions into interactions
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace App\CMS\Interactions\Admin\Content;
|
||||
|
||||
use App\CMS\Contracts\Interaction;
|
||||
use App\CMS\Enumerations\ContentStatuses;
|
||||
use App\Models\Content\Content;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
|
||||
class SetHomepage implements Interaction
|
||||
{
|
||||
/**
|
||||
* Set homepage of given page
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle($data, $parameters)
|
||||
{
|
||||
list ($page) = $parameters;
|
||||
// disable any other existing homepage
|
||||
Content::where('isHomepage', true)
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->update(['isHomepage' => false]);
|
||||
|
||||
// set new homepage
|
||||
$page->isHomepage = true;
|
||||
$page->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if status is valid
|
||||
*
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValidationRules($parameters = [])
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user