Hello!
I have create a small backend system to manage a web page. When i post something i add the date by using a bootstrap calendar plugin to a text input. What i wanted is to sort all posts in a descending order both in backend and frontend. It seems that this doesn't happen. The date form i'm using is the day/month/year.
Here is the table for the posts :
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('postDate');
$table->string('priority');
$table->string('postThumb');
$table->string('elPostTitle');
$table->text('elPostContent');
$table->string('enPostTitle');
$table->text('enPostContent');
$table->string('uri');
$table->rememberToken();
$table->timestamps();
});
}
Also here is the way i retrieve them from the Controller
public function getPosts(){
$response = array(
'status' => 0,
'message' => array(),
'posts' => array()
);
// Get all posts Data
$posts = new Post;
array_push($response['posts'], $posts::orderBy('postDate', 'DESC')->get());
return json_encode($response);
}
And at last. Here is an example of how it returns the posts order by desc date.
24/06/2005
22/05/2006
19/08/2011
18/07/2000
17/03/2008
15/09/2015
14/07/2010
14/07/1993
13/06/2007
13/01/2016
11/07/2007
10/08/2010
10/05/2010
10/01/2012
08/07/1998
07/06/2006
Is there any quick/easy way to fix this ?
Any idea/hint is welcomed!
Thank you.