davide-casiraghi/laravel-events-calendar

View on GitHub
src/Models/EventCategory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace DavideCasiraghi\LaravelEventsCalendar\Models;

use Astrotomic\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;

class EventCategory extends Model
{
    /***************************************************************************/
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'event_categories';

    /***************************************************************************/

    use Translatable;

    public $translatedAttributes = ['name', 'slug'];
    protected $fillable = [];
    public $useTranslationFallback = true;

    /***************************************************************************/

    /*
     * Return the category name.
     *
     * @param  int  $categoryId
     * @return string
     */
    public static function getCategoryName($categoryId): string
    {
        $ret = self::find($categoryId)->name;

        return $ret;
    }
}