Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Backpack\CRUD\CrudTrait;
- class Subscriber extends Model
- {
- use CrudTrait;
- use \Venturecraft\Revisionable\RevisionableTrait;
- protected $table = 'subscribers';
- protected $primaryKey = 'id';
- public $timestamps = false;
- protected $dates = ['create_date'];
- protected $fillable = ['email', 'create_date', 'visibility', 'active', 'place', 'lon', 'lat'];
- protected $hidden = ['id'];
- public static function boot()
- {
- parent::boot();
- }
- public function reports()
- {
- return $this->belongsToMany('App\Models\Report', 'report_subscribers', 'Subscribers_id', 'Report_id');
- }
- public function category()
- {
- return $this->belongsToMany('App\Models\Category', 'subscriber_category', 'subscriber_id', 'category_id');
- }
- // public function log(){
- // return $this->belongsToMany('App\Models\Reportlog', 'report_log', 'subscriber_id', 'report_id');
- // }
- public function logReport($report_id, $subscriber_id){
- $time = time();
- \DB::table('report_log')->insert(
- [ 'report_id' => $report_id,
- 'subscriber_id' => $subscriber_id,
- 'create_date'=>$time]
- );
- }
- public function setEmailAttribute($value){
- $this->attributes['email'] = $value;
- $this->attributes['create_date'] = time();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement