Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel get second last record

$row = News::count();
        $newsid = $row -2;
        $news1 = News::all()->last();
        $news2 = News::orderBy('created_at', 'desc')->skip($newsid)->take($newsid)->first();
        return view('user/start', compact('news1', 'news2', 'newsid'));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #record
ADD COMMENT
Topic
Name
7+3 =