示例#1
0
 public function postCadastro()
 {
     $dados = Input::all();
     $file = Input::file('foto');
     unset($dados["foto"]);
     if ($file != null) {
         // salva a foto
         $extension = $file->getClientOriginalExtension();
         $path = "../app/uploads/tipo/";
         if (!is_dir($path)) {
             if (!mkdir($path, 0777, true)) {
                 return 0;
             }
         }
         $filename = date('Y-m-d-H-i-s') . "." . $extension;
         $nome_foto = $path . $filename;
         $file->move($path, $filename);
     }
     if (isset($nome_foto)) {
         $dados["foto_url"] = "../" . $nome_foto;
     }
     $tipo = new TipoPratoModel($dados);
     $status = $tipo->save();
     if ($status) {
         return 1;
     } else {
         return 0;
     }
 }