Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 模型非序列化时的误差_Php_Laravel_Eloquent_Laravel 5.3 - Fatal编程技术网

Php 模型非序列化时的误差

Php 模型非序列化时的误差,php,laravel,eloquent,laravel-5.3,Php,Laravel,Eloquent,Laravel 5.3,在我的生产系统上,在队列执行中取消序列化用户对象时发生错误: [2016-12-20 21:10:01] production.ERROR: Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\User]. in /var/www/virtual/bob/bobnet/vendor/laravel/framework/src/Illuminate/Database/Eloquen

在我的生产系统上,在队列执行中取消序列化用户对象时发生错误:

[2016-12-20 21:10:01] production.ERROR: Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\User]. in /var/www/virtual/bob/bobnet/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:210
    Stack trace:
    #0 /var/www/virtual/bob/bobnet/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(45): Illuminate\Database\Eloquent\Builder->findOrFail(137)
如果我跑

\App\User::findOrFail(137)
可以在没有错误的情况下找到正确的用户。直到几周前,一切都很顺利。就像我的开发系统上的非序列化一样。 有人知道怎么回事吗

通知:

<?php

namespace App\Mail;

use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;

class GuideNotification extends Mailable
{
    use Queueable, SerializesModels;

    // Once the data has been set to a public property, it will automatically be available in the view
    private $template;
    public $user;
    public $tour;
    public $pivot;
    public $sender;
    public $date;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($template = 'emails.status_update', \App\User $user, \App\Tour $tour, $pivot, \App\User $sender = null)
    {
        $this->template = $template;
        $this->user     = $user;
        $this->tour     = $tour;
        $this->date     = new Carbon($tour->start);
        $this->pivot    = $pivot;
        if ($sender) {
            $this->sender = $sender->fullName();
        }

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this
            ->to($this->user->email)
            ->cc(config('bob.bcc_mail'), 'BoB')
            ->subject($this->generateSubject())
            ->view($this->template);
    }

    protected function generateSubject()
    {
        switch ($this->template) {
            case 'emails.request':
                return 'Guide Anfrage ' . $this->tour->name . ' am ' . $this->date->format('d.m.Y') . ' um ' . $this->date->format('H:i') . ' Uhr (ID ' . $this->tour->id . ')';
                break;
            case 'emails.confirmation':
                return 'Guide Bestätigung ' . $this->tour->name . ' am ' . $this->date->format('d.m.Y') . ' um ' . $this->date->format('H:i') . ' Uhr (ID ' . $this->tour->id . ')';
                break;
            case 'emails.change':
                return 'Guide Änderung ' . $this->tour->name . ' am ' . $this->date->format('d.m.Y') . ' um ' . $this->date->format('H:i') . ' Uhr (ID ' . $this->tour->id . ')';
                break;
            case 'emails.freesale':
                return 'Guide Bestätigung "geschnappte" ' . $this->tour->name . ' am ' . $this->date->format('d.m.Y') . ' um ' . $this->date->format('H:i') . ' Uhr (ID ' . $this->tour->id . ')';
                break;
            default:
                return 'Guide Statusupdate ' . $this->tour->name . ' am ' . $this->date->format('d.m.Y') . ' um ' . $this->date->format('H:i') . ' Uhr (ID ' . $this->tour->id . ')';
                break;
        }
    }
}
长话短说:

由于某些环境变量和执行上下文,队列使用了不同的php版本,这导致了此错误。强制使用正确的php版本后,一切正常。

长话短说:


由于某些环境变量和执行上下文,队列使用了不同的php版本,这导致了此错误。强制使用正确的php版本后,一切正常。

从何处调用
GuideNotification
类?您是否检查了是否将正确的用户对象传递给构造?从何处调用
GuideNotification
类?您是否检查了是否将正确的用户对象传递给构造?