43 lines
1011 B
PHP
43 lines
1011 B
PHP
<?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 [];
|
|
}
|
|
} |