Laravel Eloquent ORM查询

Laravel Eloquent ORM query

我一直在尝试将此 mysql 查询转换为 laravel 查询,但我无法弄清楚。

SELECT max(a.date) as max FROM table1 a, table2 b where
a.publishing_time<='2015-02-27 12:30:00' and a.Status='1' and 
a.id=b.table1_id

table 1 个字段是:-

 sl | date | publishing_time | status

table 2个字段是

 sl | table1_id | additional_fields

我被卡住了,请帮助我

试试这个..

这是laravel加入查询

 $resource = DB::table('table1')->join('table2', 'table1.id', '=', 'table2.table1_id')->where('table1.publishing_time','<=','2015-02-27 12:30:00')->where('table1.Status','1');

试试这样的东西:

DB::table('table a as a')->join('table b as b', 'a.id', '=', 'b.table1_id')->max('a.data as max')->where('a.publishing_time', '<=', '2015-02-27 12:30:00')->where('a.status', 1)->get();

试试这个 Laravel 查询

DB::table('table1 as a')
->select(DB::raw('max(a.date) as max_date'))
->join('table 2 as b', 'a.id', '=', 'b.table1_id')
->where('a.publishing_time'<='2015-02-27 12:30:00')
->where(Status='1')
->get();