在我的Laravel應用程序中出現以下錯誤,有人可以幫助我排除此異常嗎?SerializableClosure.php中的Laravel FatalErrorException
FatalErrorException在SerializableClosure.php(153):EVAL()'d代碼 第2行:調用一個成員函數getOwnerEmail()上陣列
我的吸氣劑是在Notices.php模型:
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Notice extends Model {
/**
* A notice is created by a user
* @return [type] [description]
*/
public function user()
{
return $this->belongsTo('App\User');
}
/**
* Get the email address of the notice
* @return [type] [description]
*/
public function getOwnerEmail()
{
return $this->user->email;
}
NoticesController.php
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Provider;
use App\Notice;
use Illuminate\Http\Request;
class NoticesController extends Controller {
public function store(Request $request)
{
$notice = $this->createNotice($request);
\Mail::queue('emails.dmca', compact('notice'), function($message) use ($notice) {
$message->from($notice->getOwnerEmail())
->to($notice->getRecipientEmail())
->subject('DMCA Notice');
});
return redirect('notices');
}
public function createNotice(Request $request)
{
$notice = session()->get('dmca') + ['template' => $request->input('template')];
\Auth::user()->notices()->create($notice);
return $notice;
}
public function create()
{
// get list of providers
$providers = Provider::lists('name', 'id');
return view('notices.create', compact('providers'));
}
的'Notice'反對你使用的不是一個模型對象,它是一個數組,你是怎麼得到的'$ notice'變量,表明它的使用。 –
請檢查更新後的文章 – Imran
請顯示'createNotice'。 –