first(); return view('home', ['version' => $version->value]); } public function newVersion(Request $request) { $version = Setting::where('key', 'version')->first(); $version->value = $version->value + 1; $version->save(); return redirect()->route('home'); } /** * Récupérer les contacts (csv) et les fichiers */ public function getContacts() { // generate csv $csv_file = 'contact.csv'; $csvExporter = new \Laracsv\Export(); $contacts = Contacts::all(); $csvExporter->beforeEach(function ($contact) { $contact->phone = "$contact->phone"; }); $csvExporter->getWriter()->setDelimiter(';'); $csvExporter->getWriter()->setEnclosure('"'); $csvExporter->getWriter()->setOutputBOM(\League\Csv\Reader::BOM_UTF8); $csvExporter->build($contacts, ['owner_name' => 'Propriétaire', 'email' => 'Email', 'type' => 'Type du contact', 'other' => 'Type autre', 'network' => 'Réseau commercial', 'name' => 'Nom', 'firstname' => 'Prénom', 'office' => 'Poste', 'company' => 'Entreprise', 'address' => 'Adresse', 'phone' => 'Téléphone', 'notes' => 'Notes']); Storage::disk('public')->put($csv_file, $csvExporter->getWriter()->getContent()); return response()->download(storage_path('app/public/') . "$csv_file", 'contacts.csv', ['Content-Type' => 'text/csv; charset=utf-8'])->deleteFileAfterSend(); } }