Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nicho's avatar
Level 1

Laravel : Send Email

Hi, i'm currently developing a web project. Yesterday the status issue has been resolved, and now what i want to do is. When the admin click the finish button, it change the status and send an email to the user. But i got this error that said "Class 'Modules\Booking\Controllers\MyTestMail' not found". How do i resolve this??

The Controller :

<?php
namespace Modules\Booking\Controllers;

use App\Notifications\AdminChannelServices;
use App\User;
use App\Mail\MyTestEmail;//tambahan Nicho
use DebugBar\DebugBar;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Mail;//tambahan Nicho
use Mockery\Exception;
//use Modules\Booking\Events\VendorLogPayment;
use Modules\Booking\Events\BookingCreatedEvent;
use Modules\Booking\Events\BookingUpdatedEvent;
use Modules\Booking\Events\EnquirySendEvent;
use Modules\Booking\Events\SetPaidAmountEvent;
use Modules\Tour\Models\TourDate;
use Validator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Modules\Booking\Models\Booking;
use Modules\Booking\Models\Enquiry;
use App\Helpers\ReCaptchaEngine;

public function finish($id){
        $booking = Booking::find($id);

        $booking->status = 'Finish';

        $booking->save();
        
        $isi_email = [
            'title'=>'Thank you for your purchase',
            'body'=>'Thank you for your booking. Link : https://youtu.be/dQw4w9WgXcQ'
        ];
        Mail::to('[email protected]')->send(new MyTestMail($isi_email));

        return redirect()->back();
    }

The Route :

Route::post('/finish/{id}','BookingController@finish')->name('booking.finish');

The Blade file :

@if($booking->status == 'paid')
            <form action="{{route('booking.finish', $booking->id)}}" method="POST">
                @csrf
                <button type="submit" class="btn btn-success">
                    {{__("Finish")}}
                </button>
            </form>
        @endif
0 likes
4 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You need to use the class at the top of the file

use App\Mail\MyTestMail;
Sinnbeck's avatar

@Nicho can you show the updated controller? And did the error change?

Nicho's avatar
Level 1

@Sinnbeck Oops my bad XD, i didn't realize i had a typo at the controller, it did help, thank you so much sir :D

Please or to participate in this conversation.