-
app/Mail/SuggestedResourceRejectionEmail.php
Open in GitHubuse App\Models\SuggestedResource; use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; class SuggestedResourceRejectionEmail extends Mailable { use Queueable, SerializesModels; protected $suggestedResource; protected $user; public function __construct(SuggestedResource $suggestedResource, User $user) { $this->suggestedResource = $suggestedResource; $this->user = $user; } public function build() { return $this->subject('Your Resource Has Been Reviewed') ->from(config('mail.from.address')) ->markdown('emails.rejected-resource') ->with([ 'resource' => $this->suggestedResource, 'user' => $this->user, ]); } }
-
resources/views/emails/rejected-resource.blade.php
Open in GitHub@component('mail::message') Hello {{ $user->name }}, The resource you suggested on [Onramp]({{ route('welcome', ['locale' => 'en']) }}) has been rejected by one of our reviewers: @component('mail::panel') {{ $resource->name }}<br> [Resource URL]({{ $resource->url }}) ###### *Submitted on {{ $resource->created_at->format('d-m-Y') }}* **{{ $resource->rejected_reason }}** @endcomponent We thank you for your contribution and encourage you to submit new resources that may be useful to the community. @endcomponent
-
app/Nova/Actions/RejectSuggestedResource.php
Open in GitHubuse App\Mail\SuggestedResourceRejectionEmail; use Laravel\Nova\Fields\ActionFields; use App\Models\SuggestedResource; class RejectSuggestedResource extends Action { // public function handle(ActionFields $fields, Collection $suggestedResources) { foreach ($suggestedResources as $model) { $model->update([ 'status' => SuggestedResource::REJECTED_STATUS, 'rejected_reason' => $fields->reason_for_rejection, ]); $user = User::find($model->user_id); Mail::to($user->email)->queue(new SuggestedResourceRejectionEmail($model, $user)); } } // }