4 months ago

How to use HasCompositeKey in model

Posted 4 months ago by muazzamazaz

I have added following package

into laravel and getting following error

App\Traits\HasCompositeKey::setKeysForSaveQueryMissing part of the primary key: destination_id


namespace App\Models;
use App\Traits\HasCompositeKey;

use Illuminate\Database\Eloquent\Model;

class Commission extends Model
    use HasCompositeKey;
    protected $table = 'commission';
    protected $primaryKey = ['destination_id','effective_date'];
public $incrementing = false;

    protected $fillable = [
              public function Destination()
        return $this->belongsTo('App\Models\Destination');



 $commission = Commission::where('destination_id',$id)->where('effective_date',$request->effective_date)->first();

        $input = Input::only('destination_id','effective_date', 'ticketPrice','commPercentage');       


Please sign in or create an account to participate in this conversation.