<?php

namespace App\Model\Table;

use Cake\ORM\Table;

class BundlesTable extends Table
{
    public function initialize(array $config)
    {
        $this->addBehavior('Timestamp');
        $this->belongsTo('Users');
        $this->hasMany('Links');
    }

    public function getNewBundleId($user_id)
    {
        $user= $this->Users->find()
            ->select(['last_bundle_id'])
            ->where(['id' => $user_id])
            ->first();

        return $user->last_bundle_id + 1;
    }
}
