Did you include this in your base layout?
<body>
{{ $slot }}
@include('sweetalert2::index')
</body>
Also check if there was console error
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, Using laravel 12 and the package: Laravel Excel.
https://docs.laravel-excel.com/3.1/imports/validation.html
I have an excel file with these column names:
Batch, Time, Profile, Beans, In (g), Out (g)
Example for the Time value: 2026-05-17 13:39
Example for the Profile value: Brazil-5kg-Med-03
I need to check a table in the database for existing records for:
roasted_date: 2026-05-17 13:39:00
coffee_id: 3
If a record exists, I need to give an error.
In my import class I have this method:
public function collection(Collection $rows)
{
foreach ($rows as $row) {
$date = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['time'])->format('Y-m-d H:i:00');
$dets = explode("-", $row['profile']);
$coffee_name = $dets[0];
$coffee_id = Coffee::where('short_name', $coffee_name)->value('id');
$find_duplicate = Roast::where('roast_date_time', $date)
->where('coffee_id', $coffee_id)->count();
if ($find_duplicate > 0) {
Swal::fire([
'title' => 'Error',
'text' => "Profile already uploaded",
'icon' => 'error',
]);
Log::debug('error');
return redirect()->route('warehouse.upload-roasts');
}
public function rules(): array
{
return [
'out_g' => ['exclude_if:*.batch,SUM', 'required', 'numeric'],
'beans' => ['exclude_if:*.batch,SUM', 'required', 'exists:green_beans,name'],
'profile' => function (string $attribute, mixed $value, Closure $fail) {
$dets = explode("-", $value);
$coffee_name = $dets[0];
$coffee = Coffee::where('short_name', $coffee_name)->first();
if (is_null($coffee)) {
$fail("The coffee name is invalid.");
}
},
];
}
It finds a duplicate (I get the Log debug message), but I don't get the Swal message.
I couldn't find a way to add this validation to the validation errors in the documentation, or I don't really understand their examples for complex validations, that's why I'm trying it that way.
Can someone please help?
Please or to participate in this conversation.