public function create()
 {
     $field_id = DB::table('fields')->where('field', '=', Input::get('spec'))->where('level', '=', Input::get('level'))->get()[0]->id;
     $thesis = new Thesis();
     $thesis->subject = Input::get('subject');
     $thesis->descr = Input::get('description');
     $thesis->field_id = $field_id;
     //Input::get('level');
     $thesis->lecturer_id = Auth::user()->id;
     $thesis->date = date("Y");
     $thesis->save();
     return Redirect::to('');
 }
    sleep(2);
    echo '<h4 class="alert alert-error">Error</h4>';
    echo '<hr>';
    echo 'Your thesis attachment is bigger than the maximum file size of 2MB';
    die;
}
$thesis->comment_on_field = $_POST['proposed_field_brief'];
$thesis->applicant_id = $session->applicant_id;
$thesis->thesis_topic = $_POST['proposed_thesis_topic'];
$thesis->proposal_on_thesis = $_POST['thesis_proposal'];
$initiafilename = $_FILES['attach_thesis_proposal']['name'];
$thesis_details = $thesis->find_by_id($session->applicant_id);
if (!empty($thesis_details)) {
    $thesis->thesis_id = $thesis_details->thesis_id;
}
if ($thesis->save()) {
    if (!empty($_FILES['attach_thesis_proposal'])) {
        $files = new Files();
        //$file_details = $files->find_by_id($session->applicant_id);
        /*find file record for proposed thesis*/
        $sql_thesis_upload_file = "SELECT * FROM files WHERE applicant_id=" . $session->applicant_id . " AND caption='Thesis Proposal'";
        $result_thesis_upload_file = Files::find_by_sql($sql_thesis_upload_file);
        foreach ($result_thesis_upload_file as $row) {
            $thesis_file_id = $row->file_id;
            $thesis_filename = $row->filename;
        }
        $files->upload_dir = "documents" . DS . "thesis";
        if (!empty($thesis_file_id) && !empty($_FILES['attach_thesis_proposal']['name'])) {
            $files->file_id = $thesis_file_id;
            unlink(SITE_ROOT . DS . "documents" . DS . "thesis" . DS . $thesis_filename);
        }