3 namespace BookStack\Exports\Controllers;
5 use BookStack\Exports\ZipExports\ZipExportValidator;
6 use BookStack\Http\Controller;
7 use Illuminate\Http\Request;
9 class ImportController extends Controller
11 public function __construct()
13 $this->middleware('can:content-import');
16 public function start(Request $request)
18 // TODO - Show existing imports for user (or for all users if admin-level user)
20 return view('exports.import', [
21 'zipErrors' => session()->pull('validation_errors') ?? [],
25 public function upload(Request $request)
27 $this->validate($request, [
28 'file' => ['required', 'file']
31 $file = $request->file('file');
32 $zipPath = $file->getRealPath();
34 $errors = (new ZipExportValidator($zipPath))->validate();
36 session()->flash('validation_errors', $errors);
37 return redirect('/import');
41 // TODO - Upload to storage
42 // TODO - Store info/results for display:
44 // - name (From name of thing being imported)
50 // - created_at/updated_at
51 // TODO - Send user to next import stage