Skip to content

Commit 0ab8af3

Browse files
committed
Fixed what needed fixing and squished some bugs. 🐛
1 parent d43026b commit 0ab8af3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Models/Lead.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace Tepuilabs\SimpleCrm\Models;
44

5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
56
use Illuminate\Database\Eloquent\Model;
6-
use Tepuilabs\SimpleCrm\Models\Enums\LeadStatus;
77
use Illuminate\Database\Eloquent\Relations\HasMany;
8-
use Illuminate\Database\Eloquent\Factories\HasFactory;
8+
use Illuminate\Database\Eloquent\Relations\MorphMany;
9+
use Tepuilabs\SimpleCrm\Models\Enums\LeadStatus;
910

1011
/**
1112
* @url https://www.hipb2b.com/blog/lead-prospect-whats-difference
@@ -29,16 +30,16 @@ class Lead extends Model
2930
protected $casts = [
3031
'status' => LeadStatus::class,
3132
'type' => LeadStatus::class,
32-
];
33+
];
3334

3435
/**
3536
* Notes relationship
3637
*
37-
* @return HasMany
38+
* @return MorphMany
3839
*/
39-
public function notes(): HasMany
40+
public function notes(): MorphMany
4041
{
41-
return $this->hasMany(\Tepuilabs\SimpleCrm\Models\Note::class);
42+
return $this->morphMany(\Tepuilabs\SimpleCrm\Models\Note::class, 'commentable');
4243
}
4344

4445
/**

src/Models/Note.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public function author(): MorphTo
3232
return $this->morphTo();
3333
}
3434

35+
public function commentable(): MorphTo
36+
{
37+
return $this->morphTo();
38+
}
39+
3540
public function lead(): BelongsTo
3641
{
3742
return $this->belongsTo(\Tepuilabs\SimpleCrm\Models\Lead::class);

0 commit comments

Comments
 (0)