Skip to content

Instantly share code, notes, and snippets.

@that0n3guy
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save that0n3guy/e8c25b6146f5b5b896ed to your computer and use it in GitHub Desktop.
Save that0n3guy/e8c25b6146f5b5b896ed to your computer and use it in GitHub Desktop.
ocalist model and contact model
<?php namespace OCA\Blasts\Models;
use Model;
/**
* Contact Model
*/
class Contact extends Model
{
/**
* @var string The database table used by the model.
*/
public $table = 'oca_blasts_contacts';
/**
* @var array Guarded fields
*/
protected $guarded = ['*'];
/**
* @var array Fillable fields
*/
protected $fillable = ['firstname','lastname','name','email','phone'];
/**
* @var array Validation rules
*/
public $rules = ['phone'=>'required'];
/**
* @var array Relations
*/
public $morphToMany = [
'lists' => ['OCA\Blasts\Models\Ocalist', 'table' => 'oca_blasts_ocalistables', 'name'=>'ocalistable'], // @todo need timestamps
];
}
<?php namespace OCA\Blasts\Models;
use Model;
/**
* Ocalist Model
*/
class Ocalist extends Model
{
/**
* @var string The database table used by the model.
*/
public $table = 'oca_blasts_ocalists';
/**
* @var array Guarded fields
*/
protected $guarded = ['*'];
/**
* @var array Fillable fields
*/
protected $fillable = ['name'];
/**
* @var array Validation rules
*/
public $rules = ['name'=>'required'];
/**
* @var array Relations
*/
public $morphedByMany = [
'contacts' => ['OCA\Blasts\Models\Contact', 'table' => 'oca_blasts_ocalistables', 'name'=>'ocalistable'],
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment