Exemple #1
0
 function view($unit_id)
 {
     $app = get_app();
     $unit = Unit::find_by_id($unit_id);
     if ($unit) {
         $app->render('Units/view.php', compact('unit'));
     }
 }
Exemple #2
0
 function upload_for_unit($unit_id)
 {
     $app = get_app();
     // GET
     if ($app->request()->isGet()) {
         $app->render('Images/upload.php', array('type' => 'unit', 'id' => $unit_id));
     }
     // POST
     if ($app->request()->isPost()) {
         $unit = Unit::find_by_id($unit_id);
         if ($unit) {
             $results = \Controller\Images::upload();
             if ($results['is_success']) {
                 $unit->image = $results['md5_name'];
                 $unit->save();
             }
             echo json_encode($results);
         }
     }
 }