#89 Fix duplicated relationship generated in CondrgroupUserTableSeeder

state: closed opened by: elis47 on: 5/16/2017

Comments


from: adrianharabula on: 6/6/2017

Nu avem constrângere în baza de date, dar nu e cazul, pentru că facem verificarea la introducerea în baza de date.

    public function addFavoriteGroup($groupId, $userId = null)
    {
        if ($this->existsUserFavoriteGroup($groupId, $userId))
            return false;

        $this->attachUserFavoriteGroup($groupId, $userId);

        return true;
    }

    public function existsUserFavoriteGroup($groupId, $userId = null)
    {
        return $this->getUserFavoriteGroups($userId)->contains($groupId);
    }

    public function attachUserFavoriteGroup($groupId, $userId = null)
    {
        $this->getUser($userId)->groups()->syncWithoutDetaching($groupId);
    }

results matching ""

    No results matching ""