I have following Eloquent model:

class Song extends Eloquent {

protected $table = 'mg_songs';
protected $hidden = array('events');
protected $appends = array('lastDate');

public function events()
{
    return $this-&gt;belongsToMany('Event', 'song_event');
}

public function getLastDateAttribute()
{
    if (!$this-&gt;events) return null;

    return $this-&gt;events[0]-&gt;date-&gt;formatLocalized('%d.%m.%Y (%a, %Hч)');
}}


Is it possible to sort by "lastdate" field same as db field:

$songs-&gt;orderBy('title', 'asc'); - works
$songs-&gt;orderBy('lastDate', 'desc'); - doesn't works


May be exist simple answer?

EDITED:

My db structure (only needed fields), with many-to-many:

events table
event_id
date

songs table
song_id
title

song_event pivot table
id
song_id
event_id

SQL-request:

SELECT s.title, (SELECT MAX(e.date) FROM events e JOIN song_event se ON (e.id = se.event_id) WHERE se.song_id = s.id) AS s_date FROM mg_songs s ORDER BY s_date desc



Question: what is best way to Migrate Content from Tridion 5.3sp1 to 2011sp1
Answer: You might want to consider upgrading your content porter to 2009 SP1. It is compatible with 5.3 SP 1 and 2011 SP1 as well.

There is probably no way to carry out a migration without a freeze period but using a one-time database upgrade and content porter, you could keep it to a minimum.

You might also want to consider a design freeze ( no schema or template changes ), based on your blueprint and port ONLY content changes done later across 2 environments, keeping risk to a minimum.

I hope it helps. Good luck convincing the authors :).