Пример #1
0
 public function exportPdf($ids = null)
 {
     $ids = explode(',', substr($ids, 0, -1));
     $ids = array_unique($ids);
     $model = Room::whereIn('id', $ids)->where('user_id', \Auth::user()->id)->get(['nom_salle', 'capacite_salle']);
     Excel::create('La liste des salles', function ($excel) use($model, $ids) {
         $excel->sheet('La liste des salles', function ($sheet) use($model, $ids) {
             $sheet->fromModel($model);
             $sheet->setAllBorders('thin');
             $sheet->setFontFamily('OpenSans');
             $sheet->setFontSize(13);
             $sheet->setFontBold(false);
             $sheet->setAllBorders('thin');
             for ($i = 1; $i <= count($ids) + 1; $i++) {
                 $sheet->setHeight($i, 25);
                 $sheet->row($i, function ($rows) {
                     $rows->setFontColor('#556b7b');
                     $rows->setAlignment('center');
                 });
                 $sheet->cells('A' . $i . ':' . 'B' . $i, function ($cells) {
                     $cells->setValignment('middle');
                     $cells->setFontColor('#556b7b');
                     $cells->setFont(array('family' => 'OpenSans', 'size' => '13', 'bold' => false));
                 });
             }
             // normal header
             $sheet->cells('A1:B1', function ($cells) {
                 $cells->setBackground('#e9f1f3');
                 $cells->setFontColor('#556b7b');
                 $cells->setFont(array('family' => 'OpenSans', 'size' => '15', 'bold' => true));
             });
             $sheet->row(1, array('Salle', 'Capacité de la Salle'));
         });
     })->export('pdf');
 }
 /**
  * @param Requests\TimeslotRequest $request
  * @return \stdClass
  */
 public function getFormInput(Requests\TimeslotRequest $request)
 {
     $input = new \stdClass();
     $input->day = Day::find($request->get('day_id'));
     $input->begin = Carbon::createFromFormat('d-m-Y H:i:s', $request->get('begin'));
     $input->end = Carbon::createFromFormat('d-m-Y H:i:s', $request->get('end'));
     $roomIds = array_flatten($request->get('rooms'));
     $roomIds = array_map('intval', $roomIds);
     $input->rooms = Room::whereIn('id', $roomIds)->get();
     return $input;
 }