-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from EscolaLMS/feature/dictionary-product
Register Dictionary class as product
- Loading branch information
Showing
3 changed files
with
208 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use EscolaLms\Cart\Contracts\Productable; | ||
use EscolaLms\Cart\Contracts\ProductableTrait; | ||
use EscolaLms\Cart\Models\Product; | ||
use EscolaLms\Core\Models\User; | ||
use EscolaLms\Courses\Events\CourseAccessStarted; | ||
use EscolaLms\Courses\Events\CourseAssigned; | ||
use EscolaLms\Courses\Events\CourseFinished; | ||
use EscolaLms\Courses\Events\CourseUnassigned; | ||
use EscolaLms\Dictionaries\Models\Dictionary as BaseDictionary; | ||
|
||
class Dictionary extends BaseDictionary implements Productable | ||
{ | ||
use ProductableTrait; | ||
|
||
public function attachToUser(User $user, int $quantity = 1, ?Product $product = null): void | ||
{ | ||
$this->users()->syncWithoutDetaching($user->getKey()); | ||
} | ||
|
||
public function detachFromUser(User $user, int $quantity = 1, ?Product $product = null): void | ||
{ | ||
$this->users()->detach($user->getKey()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.