| @@ -3,8 +3,10 @@ | ||
| 3 | 3 | namespace FluentBooking\App\Models; |
| 4 | 4 | |
| 5 | 5 | class BookingActivity extends Model |
| 6 | 6 | { |
| 7 | + const TYPE_NOTE = 'note'; | |
| 8 | + | |
| 7 | 9 | protected $table = 'fcal_booking_activity'; |
| 8 | 10 | |
| 9 | 11 | protected $guarded = ['id']; |
| 10 | 12 | |
| @@ -31,7 +33,19 @@ | ||
| 31 | 33 | |
| 32 | 34 | public function booking() |
| 33 | 35 | { |
| 34 | 36 | return $this->belongsTo(Booking::class, 'booking_id'); |
| 37 | + } | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Host notes only. System rows stay on the unscoped relation, so a note | |
| 41 | + * query cannot rewrite an email log or a cancellation reason. | |
| 42 | + * | |
| 43 | + * @param \FluentBooking\Framework\Database\Query\Builder $query | |
| 44 | + * @return \FluentBooking\Framework\Database\Query\Builder | |
| 45 | + */ | |
| 46 | + public function scopeNotes($query) | |
| 47 | + { | |
| 48 | + return $query->where('type', self::TYPE_NOTE); | |
| 35 | 49 | } |
| 36 | 50 | |
| 37 | 51 | } |