Last active
March 6, 2018 01:48
-
-
Save the7th/613ec099f36fddbb13184239fc94b4b2 to your computer and use it in GitHub Desktop.
Laravel Eloquent LIMIT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// below is just a sample code | |
$specificProject = DB::table('projects') | |
->select('projects.id', 'projects.project_name', 'projects.progress_percent', 'projects.project_note_id', 'projects.project_status', 'project_notes.notes', 'project_timeline.start_date', 'project_timeline.end_date', 'assigned_project.id', 'assigned_project.project_assigned_to_user', 'users.name') | |
->join('project_notes', 'projects.id', '=', 'project_notes.project_id') | |
->join('project_timeline', 'projects.id', '=', 'project_timeline.project_id') | |
->join('assigned_project', 'projects.id', '=', 'assigned_project.project_id') | |
->join('users', 'assigned_project.project_assigned_to_user', '=', 'users.id') | |
->orderBy('project_notes.id', 'DESC') | |
->take(1) // this is the limit function in Laravel Eloquent | |
->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment