为什么Laravel Models提供null,而查询构建器返回一个值

时间:2018-01-22 09:57:15

标签: php mysql laravel-5

模型运动所有其他模型与laravel模型结构工作正常,但在这个模型上它给null我不知道我想知道原因的原因。

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Auth;

class Campaign extends Model
{
    protected $table = 'campaigns';
    public $timestamps = true;


    use SoftDeletes;

    protected $dates = ['deleted_at'];
    protected $fillable = [
        'name',
        'campaign_type_id',
        'medium_type_id ',
        'pause ',
        'uuid',
        'resend_to_days',
        'trigger_mailing',
        'send_to_all',
        'email_id',
        'created_by'
    ];
}

控制器值:

// returns null
$campaign = Campaign::where('uuid',  $campaign_uuid)->first();
// returns value
$campaign = DB::table('campaigns')->where('uuid', '=', $campaign_uuid)->first();

0 个答案:

没有答案