<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Predefined extends Model {

    /**
     * @primaryKey string - primry key column.
     * @dateFormat string - date storage format
     * @guarded string - allow mass assignment except specified
     * @CREATED_AT string - creation date column
     * @UPDATED_AT string - updated date column
     */
    protected $table = 'predefined';
    protected $primaryKey = 'predefined_id';
    protected $dateFormat = 'Y-m-d H:i:s';
    protected $guarded = ['predefined_id'];
    const CREATED_AT = 'predefined_created';
    const UPDATED_AT = 'predefined_updated';

    /**
     * relatioship business rules:
     *         - the Creator (user) can have many Predefined
     *         - the Predefined belongs to one Creator (user)
     */
    public function creator() {
        return $this->belongsTo('App\Models\User', 'predefined_creatorid', 'id');
    }

}
