コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     Excel::create('Prestamos', function ($excel) {
         $excel->setTitle('Lista de prestamos');
         $excel->sheet('prestamos', function ($sheet) {
             //$prestamos = Prestamo::all();
             $prestamos = Prestamo::select('id', 'comentario', 'fecha_inicio', 'fecha_fin', 'fecha_entrega', 'libro_id')->get();
             $sheet->fromArray($prestamos);
             //$sheet->setFontFamily('Comic Sans MS');
             $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 12, 'bold' => true)));
         });
     })->export('pdf');
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(\App\Instrumento::class, 50)->create()->each(function ($e) {
         $set = 1;
         for ($i = 0; $i < 10; $i++) {
             if ($e->estado_prestamo == 'disponible') {
                 $prestamo = \App\Prestamo::create(['usuario_presta' => rand($min = 1, $max = 20), 'usuario_recibe' => rand($min = 1, $max = 20), 'laboratorio_id' => rand($min = 1, $max = 12), 'curso_id' => rand($min = 1, $max = 12), 'instrumento_id' => rand($min = 1, $max = 50), 'estado_prestamo' => 'terminado', 'mail' => '*****@*****.**', 'telefono' => '11111111']);
                 $e->prestamos()->save($prestamo);
             } else {
                 if ($set == 1) {
                     $prestamo = \App\Prestamo::create(['usuario_presta' => rand($min = 1, $max = 20), 'usuario_recibe' => rand($min = 1, $max = 20), 'laboratorio_id' => rand($min = 1, $max = 12), 'curso_id' => rand($min = 1, $max = 12), 'instrumento_id' => rand($min = 1, $max = 50), 'estado_prestamo' => 'abierto', 'mail' => '*****@*****.**', 'telefono' => '11111111']);
                     $e->prestamos()->save($prestamo);
                     $set = 0;
                 }
                 $prestamo = \App\Prestamo::create(['usuario_presta' => rand($min = 1, $max = 20), 'usuario_recibe' => rand($min = 1, $max = 20), 'laboratorio_id' => rand($min = 1, $max = 12), 'curso_id' => rand($min = 1, $max = 12), 'instrumento_id' => rand($min = 1, $max = 50), 'estado_prestamo' => 'terminado', 'mail' => '*****@*****.**', 'telefono' => '11111111']);
                 $e->prestamos()->save($prestamo);
             }
         }
     });
 }
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $prestamo = Prestamo::find($id);
     $prestamo->delete();
     Flash::success('El prestamo ha sido eliminado con exito!');
     return redirect()->route('admin.prestamos.index');
 }