mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-11-04 06:23:17 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			770 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			770 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Crater\Models;
 | 
						|
 | 
						|
use Illuminate\Database\Eloquent\Factories\HasFactory;
 | 
						|
use Illuminate\Database\Eloquent\Model;
 | 
						|
 | 
						|
class Note extends Model
 | 
						|
{
 | 
						|
    use HasFactory;
 | 
						|
 | 
						|
    protected $guarded = ['id'];
 | 
						|
 | 
						|
    public function scopeApplyFilters($query, array $filters)
 | 
						|
    {
 | 
						|
        $filters = collect($filters);
 | 
						|
 | 
						|
        if ($filters->get('type')) {
 | 
						|
            $query->whereType($filters->get('type'));
 | 
						|
        }
 | 
						|
 | 
						|
        if ($filters->get('search')) {
 | 
						|
            $query->whereSearch($filters->get('search'));
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    public function scopeWhereSearch($query, $search)
 | 
						|
    {
 | 
						|
        $query->where('name', 'LIKE', '%' . $search . '%');
 | 
						|
    }
 | 
						|
 | 
						|
    public function scopeWhereType($query, $type)
 | 
						|
    {
 | 
						|
        return $query->where('type', $type);
 | 
						|
    }
 | 
						|
}
 |