我需要与下面在 Laravel 5 的 SQL 查询中给出的完全相同的结果。
SELECT * FROM `customers` WHERE MONTH(birthdate) = MONTH(NOW()) // get get current month's birthday
在我的控制器中,我有这个代码。
$customer['current_dob'] = Customers::where( DB::raw('MONTH(birthdate)','=','MONTH(NOW())'))->get();
模型:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Customers extends Model
{
protected $table = 'customers';
protected $fillable = array('fname','lname','email','mobile','birthdate','aniversary','gender','amount');
}