You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
willaengine/app/Cooperation.php

39 lines
1.2 KiB

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\App;
use Kalnoy\Nestedset\NodeTrait;
use Carbon\Carbon;
class Cooperation extends Model
{
protected $table = 'cooperation';
public $fillable = ['user_id','status','comments','other','append_job' , 'created_at' , 'updated_at'];
public function User()
{
return $this->belongsTo('App\User')->select(['name','id','detail','birthday','cell_number','email']);
}
public function FormData()
{
return $this->hasMany('App\CooperationData', 'type_id')
->where('model_type' , 'App\Cooperation');
}
public function UserData()
{
return $this->hasMany('App\CooperationData', 'type_id')->where('model_type' , 'App\\User');
}
public function setAppointmentAttribute($value)
{
$carbon = new Carbon();
$date = substr($value, 0, -3);
$date = $carbon->timestamp($date)->timezone('Asia/Tehran')->toDateString();
$this->attributes['appointment'] = $date;
}
}
?>