public function get_ParcoursUserList_csv($id) { if (!Helpers::isSecr()) { return redirect('/'); } $parcours = Parcours::findOrFail($id); $users = $parcours->users; $output = fopen('php://memory', 'w'); $filename = $parcours->intitule . "_" . $parcours->specialite->intitule . '.csv'; // output the column headings fputcsv($output, array($parcours->intitule, $parcours->specialite->intitule), ';'); fputcsv($output, array('Nom', 'Prénom', '@mail', 'actif'), ';'); // loop over the rows, outputting them foreach ($users as $user) { fputcsv($output, array($user->nom, $user->prenom, $user->mail, $user->actif), ';'); } // reset the file pointer to the start of the file fseek($output, 0); // tell the browser it's going to be a csv file header('Content-Type: application/csv'); // tell the browser we want to save it instead of displaying it header('Content-Disposition: attachment; filename="' . $filename . '";'); // make php send the generated csv lines to the browser fpassthru($output); return null; }
public function post_DeleteConfirm($id) { if (!Helpers::isAdmin()) { return redirect('/'); } $text = Parcours::findOrFail($id)->intitule . " à été supprimé"; Parcours::destroy($id); return view("confirmation", ['text' => $text]); }