4
獲取ErrorException的財產Mailer.php線33:試圖讓非對象的屬性Laravel 5.1梅勒試圖讓非對象
我Mailer.php:
<?php
namespace App\Mailers;
use Illuminate\Contracts\Mail\Mailer as Mail;
abstract class Mailer
{
/**
* @var Mail
*/
protected $mail;
/**
* @param Mail $mail
*/
public function __construct(Mail $mail)
{
$this->mail = $mail;
}
/**
* @param $to
* @param $subject
* @param $from
* @param $view
* @param null $data
*/
public function mailTo($to, $subject, $from, $view, $data = null)
{
$this->mail->send($view, $data, function($message) use ($to, $from, $subject)
{
$message->to($to->email)->subject($subject)->from($from);
});
}
}
我SiteMailer。 PHP擴展我的Mailer.php抽象類
<?php
namespace App\Mailers;
class SiteMailer extends Mailer
{
/**
* @param $data
*/
public function sendEmailMessageToSupport($data)
{
$from = env('MAIL_NOREPLY', 'SUPPORT');
$to = env('MAIL_NOREPLY', 'SUPPORT');
$subject = 'Activate Your Account';
$view = 'auth.emails.support';
$this->mailTo($to, $subject, $from, $view, $data);
}
}
而且我SupportController.php
我SupportRequest FormRequest
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class SupportRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'email' => 'required|email',
'message_content' => 'required',
];
}
}
然後郵件視圖
<p>
A prospective customer named {{ $name }} <small>{{ $email }}</small>
has submitted an inquiry through Our Site.
</p>
<p>
{{ $message_content }}
</p>
無法找到問題的所在。