<?php
namespace QxCMS\Modules\Client\Models\Questionnaire;
use Illuminate\Database\Eloquent\Model;
class Template extends Model
{
protected $connection = 'client';
protected $table = 'survey_templates';
public $module_id = 5;
/*
* The attributes that are mass assignable.
*
* @var array
*/
protected $guarded = [];
protected $appends = ['hashid'];
/*
* Model Accessors
*/
public function getHashidAttribute()
{
return hashid($this->id);
}
/*
* Model Custom Functions
*/
public function questions()
{
return $this->hasMany('QxCMS\Modules\Client\Models\Questionnaire\Question', 'template_id');
}
public function scopeSearchByTitle($query, $criteria = null)
{
if(!empty($criteria))
{
return $query->where('title', 'LIKE', '%'.$criteria.'%');
}
}
}