SerializableClosure.php中的Laravel FatalErrorException

时间:2015-06-25 22:46:16

标签: php laravel laravel-5

我的Laravel应用中出现以下错误,有人可以帮我解决此异常问题吗?

  

SerializableClosure.php(153)中的FatalErrorException:eval()'代码   第2行:在数组

上调用成员函数getOwnerEmail()

我的getter在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'));

    }

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

public function createNotice(Request $request)
{
    $notice = session()->get('dmca') + ['template' => $request->input('template')];

    return \Auth::user()->notices()->create($notice);
}