<?php

namespace App\Models;

use App\Libs\Database\Eloquent\ContentTypeModel;
use App\Models\GenericBackoffice\Traits\LanguageSupportTrait;
use Illuminate\Support\Facades\DB;
use App\Services\LoginScreenDataService;

class LoginScreen extends ContentTypeModel
{
    use LanguageSupportTrait;

    protected $hidden = ['languages', "websites"];
    protected $with = ['languages', "websites"];

    protected $dates = []; // dates
    protected $casts = [];

    public function image()
    {
        return $this->belongsTo(MediaItem::class, 'image_id');
    }


    public static function boot()
    {


        LoginScreen::saved(function (LoginScreen $loginScreen) {

            //There can only be one active login screen 
            //If this one is active oll others will be deactivated
            if ($loginScreen->active) {

                LoginScreenDataService::deactivateOtherScreens($loginScreen->id);
            }
        });

        parent::boot();
    }

    /**
     * Gets the possible themes for an exhibition
     * @return array
     */
    public static function getThemes(): array
    {
        return [
            'light' => 'Light',
            'dark'  => 'Dark'
        ];
    }
}
