paginate(10) ->through(fn($profile) => [ 'id' => $profile->id, 'username' => $profile->username, 'name' => $profile->name, ]); return Inertia::render('SmartDokProfile/Index', [ 'profiles' => $profiles, 'filters' => $request->only(['search', 'page']), ]); } /** * Show the form for creating a new resource. */ public function create() { return Inertia::render('SmartDokProfile/Create'); } /** * Store a newly created resource in storage. */ public function store(Request $request) { $data = $request->validate([ 'username' => 'required|string|max:255|unique:smartdok_profiles,username', 'name' => 'required|string|max:255', ]); // generate a UUID for the new profile $data['id'] = (string) Str::uuid(); SmartdokProfile::create($data); return redirect() ->route('smartdok.profiles.index') ->with('success', 'Profile created successfully.'); } /** * Display the specified resource. */ public function show(string $id) { $profile = SmartdokProfile::findOrFail($id); return Inertia::render('SmartDokProfile/Show', [ 'profile' => [ 'id' => $profile->id, 'username' => $profile->username, 'name' => $profile->name, ], ]); } /** * Show the form for editing the specified resource. */ public function edit(string $id) { $profile = SmartdokProfile::findOrFail($id); return Inertia::render('SmartDokProfile/Edit', [ 'profile' => [ 'id' => $profile->id, 'username' => $profile->username, 'name' => $profile->name, ], ]); } /** * Update the specified resource in storage. */ public function update(Request $request, string $id) { $profile = SmartdokProfile::findOrFail($id); $data = $request->validate([ 'username' => 'required|string|max:255|unique:smartdok_profiles,username,' . $profile->id, 'name' => 'required|string|max:255', ]); $profile->update($data); return redirect() ->route('smartdok.profiles.index') ->with('success', 'Profile updated successfully.'); } /** * Remove the specified resource from storage. */ public function destroy(string $id) { $profile = SmartdokProfile::findOrFail($id); $profile->delete(); return redirect() ->route('smartdok.profiles.index') ->with('success', 'Profile deleted successfully.'); } }