{"id":12423,"date":"2020-03-19T12:32:31","date_gmt":"2020-03-19T12:32:31","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=12423"},"modified":"2021-11-12T06:26:20","modified_gmt":"2021-11-12T06:26:20","slug":"how-to-get-data-from-the-database-in-descending-order-in-laravel","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-get-data-from-the-database-in-descending-order-in-laravel\/","title":{"rendered":"How to get data from the database in descending order in laravel."},"content":{"rendered":"\n<h2 class=\"has-text-align-center has-vivid-red-color has-text-color wp-block-heading\">Through Model<\/h2>\n\n\n\n<p>To get data from the database in descending order(by default it returns in ascending order) or the latest data we have added we use <strong>latest()<\/strong> method. See the below image of code for help:-  <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"343\" height=\"74\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Through-Model.png\" alt=\"\" class=\"wp-image-12425\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Through-Model.png 343w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/03\/Through-Model-300x65.png 300w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/figure><\/div>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_65379\"><iframe loading=\"lazy\"  id=\"_ytid_62044\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_65379\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Through Model To get data from the database in descending order(by default it returns in ascending order) or the latest data we have added we use latest() method. See the&#8230; <\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[],"class_list":["post-12423","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/12423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=12423"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/12423\/revisions"}],"predecessor-version":[{"id":24886,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/12423\/revisions\/24886"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=12423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=12423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=12423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}