This code is from my Kohana project. How can I make it more beautiful? Should I use try-catch instead? How could I avoid writing exit()
twice?
public function action_index()
{
$id = $this->request->query('id');
if (!empty($id)) {
$ticket = ORM::factory('ticket')
->where('id', '=', $id)
->find();
if (!empty($ticket)) {
$event = ORM::factory('event')
->where('id', '=', $ticket->event_id)
->find();
if (!empty($event)) {
$this->template->ticket = $ticket->id;
$this->template->name = $ticket->name;
$this->template->event = $event->title;
} else {
exit();
}
} else {
exit();
}
}
}