What's this?
foreach ($plans_n as $rec) {}
And, what data in the email view template needs to be iterated over? The view template is just Blade, so @foreach works just fine. Combined with the mail::table component, everything is good...
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello some one can give me a hand with this topic? i got this:
in my Kernel file:
$schedule->call(function () {
//$plans_n = servHosting::whereMonth('created_at', '=', Carbon::now()->addMonth()->month)->get();
$plans_n= servHosting::whereMonth('created_at', '=', Carbon::now())->get();
foreach ($plans_n as $rec) {}
Mail::to('[email protected]')->send(new HostingReport ($rec));
})->everyMinute();
in my HostingReport file:
namespace App\Mail;
use App\Models\servHosting;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class HostingReport extends Mailable
{
use Queueable, SerializesModels;
public $rec;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(servHosting $rec)
{
$this->rec = $rec;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.reports.hosting')
->with([
'plan' => $this->rec->plan,
'end' => $this->rec->end_date,
'price' => $this->rec->price,
'domain' => $this->rec->domain
])
->subject('Reporte mensual de Hosting - Getweb');
}
}
in my Hosting email view file:
@component('mail::message')
# Introduction
The body of your message Hosting.
@component('mail::panel')
Resultados proximo mes
@endcomponent
// in this space is going to loop the results
@foreach ($host as $rec)
{{$rec->end}}
@endforeach
Thanks,<br>
{{ config('app.name') }}
@endcomponent
can anyone help me, please?
In Kernel file:
$plans = servHosting::whereMonth('created_at', '=', Carbon::now())->get();
Mail::to('[email protected]')->send(new HostingReport($plans));
In HostingReport:
public $plans;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($plans)
{
$this->plans = $plans;
}
public function build()
{
return $this->markdown('emails.reports.hosting')
->subject('Reporte mensual de Hosting - Getweb');
}
In view:
@component('mail::table')
| Dominio | Plan | Vencimiento | Renovacion |
| ------------- |:-------------:| --------:| --------:|
@foreach ($plans as $plan)
| {{ $plan->end }} | ... | ... | ... |
@endforeach
@endcomponent
Please or to participate in this conversation.