Completed
Push — development ( 0a823e...7b3256 )
by Ashutosh
238:19 queued 221:53
created

ChatScript::getDescriptionForEvent()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 16
c 0
b 0
f 0
rs 10
cc 4
nc 4
nop 1
1
<?php
2
3
namespace App\Model\Common;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Spatie\Activitylog\Models\Activity;
7
use Spatie\Activitylog\Traits\LogsActivity;
8
9
class ChatScript extends Model
10
{
11
	use LogsActivity;
12
    protected $table = 'chat_scripts';
13
    protected $fillable = ['name', 'script'];
14
      protected static $logName = 'Chat Script';
15
      protected static $logAttributes = ['name', 'script'];
16
        protected static $logOnlyDirty = true;
17
18
     public function getDescriptionForEvent(string $eventName): string
19
    {
20
        // dd(Activity::where('subject_id',)->pluck('subject_id'));
21
        if ($eventName == 'created') {
22
            return 'Chat Script'.$this->name.' was created';
23
        }
24
25
        if ($eventName == 'updated') {
26
            return 'Chat Script  <strong> '.$this->name.'</strong> was updated';
27
        }
28
29
        if ($eventName == 'deleted') {
30
            return 'Chat Script <strong> '.$this->name.' </strong> was deleted';
31
        }
32
33
        return '';
34
35
        // return "Product  has been {$eventName}";
36
         // \Auth::user()->activity;
37
    }
38
}
39