/** * Run the migrations. * * @return void */ public function up() { $file_insert = new TheFile(); $file_insert->name = 'FAC3363.201114'; $file_insert->date_generated = '2014-11-20'; $file_insert->user_id = 2; $file_insert->upload = 0; $file_insert->type = 'facturacion'; $file_insert->save(); }
/** * Inserto en la tabla files el archivo guardado en el servidor * Si es que ya existe va a modificar el campo updated_at **/ private function _insertFile($file_name, $type = 'facturacion') { if ($type != 'facturacion') { $type = 'cobranzas'; } $id_user = (int) Auth::id(); $file_search = DB::table('files')->where('name', $file_name)->first(); // Controlo si existe en la tabla. if (isset($file_search)) { $id_file = $file_search->id; $file = TheFile::find($id_file); $file->user_id = $id_user; $file->updated_at = date('Y-m-d G:i:s'); } else { $file = new TheFile(); $file->name = $file_name; $file->date_generated = date('Y-m-d'); $file->user_id = $id_user; $file->type = $type; } if ($file->save()) { return true; } else { return false; } }
| Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/cargo_archivo', function () { $usuario = User::find(2); $archivo = new TheFile(); $archivo->name = 'file_name_archivo.txt'; $archivo->user_id = $usuario->id; $archivo->type = 'cobranzas'; // $archivo->file()->associate($usuario); $archivo->save(); }); Route::get('/', function () { // return View::make('hello'); if (Auth::check()) { return View::make('template_tisa/homepage'); } else { return View::make('template_tisa/login'); } }); Route::get('login', array('as' => 'login_get', function () { if (Auth::check()) { return View::make('template_tisa/homepage'); } else { return View::make('template_tisa/login'); }