I have been unsuccessfully trying to leftjoin and get the required data
Here is my code:
$album = Albums::->where('users_id',$user_id)
->leftJoin('photos',function($query){
$query->on('photos.albums_id','=','albums.id');
$query->where('photos.status','=',1);
//$query->limit(1);
//$query->min('photos.created_at');
})
->where('albums.status',1)->get();
The comments are some of my several trying...
I want to get only a single record from the photos table matching the foreign key album_id
which was updated first and also with status 1
pls help...
$query->take(1);
before the two commented lines helps? – CacophonousCall to undefined method lluminate\Database\Query\JoinClause::take()
error @Cacophonous – Hatcher