1, 'barbershop_id' => 1, 'username' => 'yoga', 'email' => 'yoga@developer.com', 'password' => Hash::make(env('PASSWORD_DEFAULT_USER')), ]); // Create biography for the user Biography::create([ 'user_id' => $newUser->id, 'full_name' => 'Yoga Pangestu', 'pob' => 'Subang', 'dob' => '2000-01-01', 'contact_number' => '082121495806', 'address' => 'Jl.Babaru Nagri', 'gender' => 1, ]); // Path to the image file $imagePath = public_path('assets/admin/images/avatar/speed.jpeg'); // Check if the file exists if (file_exists($imagePath)) { // Create a Symfony file instance $file = new \Symfony\Component\HttpFoundation\File\File($imagePath); // Generate a unique file name $fileName = Str::uuid().'.'.$file->getExtension(); // Create an attachment record Attachment::create([ 'attachmentable_id' => $newUser->id, 'attachmentable_type' => User::class, 'name' => $fileName, 'extension' => $file->getExtension(), 'size' => $file->getSize(), ]); // Define the storage path for avatars $path = 'avatars/'.now()->format('Y-m-d'); // Store the file in the defined path using Storage facade Storage::disk('public')->putFileAs($path, $file, $fileName); } }); } }