HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/centrum8a/centrum8a.com/app/KommaApp/Kms/Core/Sections/SectionServiceInterface.php
<?php
/**
 * Created by PhpStorm.
 * User: julesgraus
 * Date: 23/02/2018
 * Time: 13:38
 */

namespace App\KommaApp\Kms\Core\Sections;

use App\KommaApp\Kms\Core\AbstractTranslatableModel;
use App\KommaApp\Kms\Core\AbstractTranslationModel;
use App\KommaApp\Kms\Core\Attributes\Models\SelectOptionInterface;
use App\KommaApp\Kms\Core\Tree\Tree;
use App\KommaApp\Languages\Models\Language;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;


/**
 * @see PageRepository Based of the deprecated PageRepository and KmsRepository
 *
 * Class SectionService
 * @package App\KommaApp\Shop\
 */
interface SectionServiceInterface
{
    /**
     * This method will get a model based on the id.
     * When the id is NULL or the model does not exist, we will generate a new.
     *
     * @see KmsSection::loadModel()
     * @param int $modelId
     * @return Model
     */
    public function getModel($modelId = null): Model;

    /**
     * Gets the name of the model the service does its work for.
     * WARNING! Prevent usage of this method.
     *
     * @return string
     */
    public function getForModelName(): string;

    /**
     * Gets the name of the model the service does its work for.
     * WARNING! Prevent usage of this method.
     *
     * @return string
     */
    public function getForTranslationModelName(): string;

    /**
     * Set the thumbnail for the model.
     *
     * @param Model $model
     * @param string|null $thumbnailString an image url
     * @return Model
     */
    public function setThumbnail(Model $model, string $thumbnailString = null);

    /**
     * @param AbstractTranslatableModel $model
     * @param string $thumbnailString
     * @return mixed
     */
    public function setTreeThumbnail(AbstractTranslatableModel $model, string $thumbnailString = null);

    /**
     * This method will create a new TranslatableModelInterface instance with its translations.
     *
     * @param null $siteId
     * @return Model
     */
    public function newModel($siteId = null): Model;

    /**
     * Gets the model query
     *
     * @return \Illuminate\Database\Query\Builder
     */
    public function models();

    /**
     * Gets the model query
     *
     * @return \Illuminate\Database\Query\Builder
     */
    public function translationModels();

    /**
     * Get model tree
     *
     * @return Tree
     */
    public function getModelTree($siteId = null): Tree;

    /**
     * Returns all models for the sidebar menu in the backend
     *
     * @return array
     */
    public function getModelsForSideBar(): array;

    /**
     * This method will build an model tree.
     * Based on the language-id
     * Used by the Controllers get and set-structure method
     *
     * @param null $langId
     * @return Tree
     */
    public function getModelsAsTree($langId = null): Tree;

    /**
     * This method will save an model
     *
     * @param Model $model or null
     * @param Collection $sectionTabItems These must be filled with data. This is something you need to do yourself.
     *
     * @return mixed
     */
    public function saveModel(Model $model = null, Collection $sectionTabItems): Model;

    /**
     * Returns true when the section has a sortable items list to the left side of the screen or false if not.
     *
     * @return boolean
     */
    public function getSortable();

    /**
     * @param int|null $languageId TODO: Jules. Check if we still need this
     * @param int|null $excludeId TODO: Jules. Check if we still need this
     * @return SelectOptionInterface[]
     */
    public function getOptionsForSelect($languageId = null, int $excludeId = null): array;

    /**
     * Fills attributes with data from a model in this way:
     *
     * 1. First it looks if it needs to get the value from a translationModel.
     *    If so, gets it, fills the attribute and fills the next attribute if any
     * 2. Then it looks if it needs to get the value from it's model.
     *    If so, gets it, fills the attribute and fills the next attribute if any
     * 4. Then it looks if it needs to get the value from the images associated with it.
     *    If so, gets it, fills the attribute and fills the next attribute if any
     * Please notice that if cases 1, 2 and 3 where true the value you may have set with setValue is overwritten.
     *
     * @param Collection $sectionTabItems A collection containing implementations AbstractSectionTabItem's
     * @param Model $model
     * @return Collection
     */
    public function fillAttributesWithData(Collection $sectionTabItems, Model $model);

    /**
     * This method will remove an TranslatableModelInterface instance
     *
     * @param $model
     * @throws \Exception
     */
    public function destroyModel(Model $model);

    /**
     *
     * Generate the html of the thumbnail
     *
     * @param $model
     */
    public function generateThumbnail(&$model);

    /**
     * Generate an unique slug for an Abstract translatable model
     *
     * @param AbstractTranslationModel $translation
     * @param string $name
     * @param int $uniquifier
     * @return string
     */
    function createOrGetUniqueSlug(AbstractTranslationModel $translation, string $name, int $uniquifier = 0): string;

    /**
     * Uses a model that must have a translations method, creates a new translation for it if it does not exists and associates it with the language given.
     * Returns the translation
     *
     * @param AbstractTranslatableModel $model
     * @param Language $language
     * @return Model The translation
     */
    public function getOrCreateTranslationModelForModel(AbstractTranslatableModel $model, Language $language): Model;
}