%PDF- %PDF-
Direktori : /var/www/html/kpk/api/app/Models/ |
Current File : /var/www/html/kpk/api/app/Models/Protocol.php |
<?php namespace App\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; class Protocol extends Model { protected $fillable = [ 'number', 'arrival_date', 'user_id', 'institution', 'subject_of_reevaluation', 'relator_id', 'description', 'type', 'has_confirmed_document_retrieval', 'sent_to', 'is_deleted', 'deleted_at' ]; /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { return $this->belongsTo(User::class); } public function relator() { return $this->belongsTo(Relator::class); } /** * @return bool */ public function isEditable() { $user = auth()->guard('api')->user(); $now = Carbon::now(); return $this->user_id === $user->id && $now->diff($this->created_at)->days <= 10; } public function isDeletable() { $user = auth()->guard('api')->user(); return $this->user_id === $user->id && !$this->is_deleted; } }