32 lines
614 B
PHP
32 lines
614 B
PHP
<?php
|
|
|
|
namespace App\ModelFilters;
|
|
|
|
use EloquentFilter\ModelFilter;
|
|
|
|
class CropYieldFilter extends ModelFilter
|
|
{
|
|
public function year($y)
|
|
{
|
|
$y = $y ?? date('Y'); //默认当前年份
|
|
|
|
return $this->where('time_year', $y);
|
|
}
|
|
|
|
public function quarter($quarter){
|
|
return $this->where('quarter', $quarter);
|
|
}
|
|
|
|
public function crop($cropId)
|
|
{
|
|
return $this->where('crop_id', $cropId);
|
|
}
|
|
|
|
public function type($type)
|
|
{
|
|
return $this->whereHas('base', function($q) use ($type) {
|
|
return $q->where('type', $type);
|
|
});
|
|
}
|
|
}
|