Php 从今天起的下一张唱片在拉雷维尔
我是拉拉维尔的初学者。 我在我的项目中使用了Laravel5.8 我有以下代码:Php 从今天起的下一张唱片在拉雷维尔,php,laravel,laravel-5,Php,Laravel,Laravel 5,我是拉拉维尔的初学者。 我在我的项目中使用了Laravel5.8 我有以下代码: class EventCalendar extends Model { use scopeActiveTrait; protected $quarded = ['id']; protected $fillable = ['email_responsible_person','www_responsible_person','phone_responsible_person','respon
class EventCalendar extends Model
{
use scopeActiveTrait;
protected $quarded = ['id'];
protected $fillable = ['email_responsible_person','www_responsible_person','phone_responsible_person','responsible_person', 'company_id', 'id_category', 'id_place', 'enable', 'title', 'title_on_the_list', 'content', 'short_content', 'url_address', 'date_from', 'date_to', 'hour_from', 'hour_to', 'price', 'file', 'hide_data', 'visible_on_promo_box', 'date'];
public $timestamps = false;
public function category()
{
return $this->belongsTo('App\EventCalendarCategory', 'id_category');
}
public function localization()
{
return $this->belongsTo('App\EventCalendarPlace', 'id_place');
}
}
public function getNextEventsList()
{
return EventCalendar::active()->with(['localization', 'category'])->where('visible_on_promo_box', '=', 1)->orderBy('date_from', 'ASC')->get();
}
这段代码运行良好。
我需要显示今天或第二天发生的所有记录(事件)
EventCalendar::active()->with(['localization', 'category'])->where('visible_on_promo_box', '=', 1)->whereIn('date_from',[Carbon::today(),Carbon:tomarrow()])->get()
我怎样才能做到呢?只获取今天的记录
use Carbon\Carbon;
public function getNextEventsList()
{
return EventCalendar::active()->with(['localization', 'category'])->where('visible_on_promo_box', '=', 1)->where('date_from', Carbon::today())->orderBy('date_from', 'ASC')->get();
}
找明天的唱片
use Carbon\Carbon;
public function getNextEventsList()
{
return EventCalendar::active()->with(['localization', 'category'])->where('visible_on_promo_box', '=', 1)->where('date_from', Carbon::tomorrow())->orderBy('date_from', 'ASC')->get();
}
按年份范围获取
use Carbon\Carbon;
public function getNextEventsList()
{
return EventCalendar::active()->with(['localization', 'category'])->where('visible_on_promo_box', '=', 1)->where('date_from', '>=', Carbon::now())->where('date_from', '<=', Carbon::now()->addYear())->orderBy('date_from', 'ASC')->get();
}
使用碳\碳;
公共函数getNextEventsList()
{
return EventCalendar::active()->with(['localization','category'])->where('visible_on_promo_box','=',1)->where('date_from','>=',Carbon::now())->where('date_from',',以获取今天或第二天将发生的记录
EventCalendar::active()->with(['localization', 'category'])->where('visible_on_promo_box', '=', 1)->whereIn('date_from',[Carbon::today(),Carbon:tomarrow()])->get()
好的,如果我希望所有记录从现在到1年(到未来)?我如何更改它?使用return EventCalendar::active()->with(['localization','category')->where('visible_on_promo_box','=',1)->where('date_from','>','Carbon now())->where('date_from','