laravel错误:尝试在控制器laravel上获取非对象的属性

时间:2017-03-14 00:11:47

标签: laravel

有人可以帮我解决这个问题的原因。

我无法修复查询,在$ repair->控制器中的save()之后将邮件主题设置为db字段中的一个

这个有效:

Mail::raw($body, function ($message) use ($user, $repair) {
            $message->from(Setting::where('setting_key', 'company_email')->first()->setting_value, Setting::where('setting_key', 'company_name')->first()->setting_value);
            $message->to('mail@mail.com');
            $message->setContentType('text/html');
            $message->setSubject(CustomFieldMeta::where('category', 'repairs')->where('parent_id', 108)->where('custom_field_id', 1)->first()->name);
        });

或者这个:

Mail::raw($body, function ($message) use ($user, $repair) {
            $message->from(Setting::where('setting_key', 'company_email')->first()->setting_value, Setting::where('setting_key', 'company_name')->first()->setting_value);
            $message->to('mail@mail.com');
            $message->setContentType('text/html');
            $message->setSubject($repair->id);
        });

这个我需要的女巫不能工作:

Mail::raw($body, function ($message) use ($user, $repair) {
            $message->from(Setting::where('setting_key', 'company_email')->first()->setting_value, Setting::where('setting_key', 'company_name')->first()->setting_value);
            $message->to('mail@mail.com');
            $message->setContentType('text/html');
            $message->setSubject(CustomFieldMeta::where('category', 'repairs')->where('parent_id', $repair->id)->where('custom_field_id', 1)->first()->name);
        });


error: at HandleExceptions->handleError('8', 'Trying to get property of non-object', '/public_html/app/Http/Controllers/RepairController.php', '188', array('message' => object(Message), 'user' => object(User), 'repair' => object(Repair))) in RepairController.php line 188

谢谢。

0 个答案:

没有答案