| Total Complexity | 6 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class SermonPolicy |
||
| 11 | { |
||
| 12 | use HandlesAuthorization; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Determine whether the user can view the sermon. |
||
| 16 | * |
||
| 17 | * @param Ministry $user |
||
| 18 | * @param Sermon $sermon |
||
| 19 | * |
||
| 20 | * @return mixed |
||
| 21 | */ |
||
| 22 | public function view(Ministry $user, Sermon $sermon) |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Determine whether the user can create sermons. |
||
| 29 | * |
||
| 30 | * @param Ministry $user |
||
| 31 | * |
||
| 32 | * @return mixed |
||
| 33 | */ |
||
| 34 | public function create(Ministry $user) |
||
| 35 | { |
||
| 36 | if ($user->account->level !== 'Free') { |
||
| 37 | return true; |
||
| 38 | } else { |
||
| 39 | $sermonsCount = Sermon::where('ministry_id', $user->id) |
||
| 40 | ->whereBetween('created_at', [now()->firstOfMonth(), now()->lastOfMonth()]) |
||
| 41 | ->count(); |
||
| 42 | if ($sermonsCount >= SermonHelper::$freeSermonsCount) { |
||
| 43 | return false; |
||
| 44 | } else { |
||
| 45 | return true; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Determine whether the user can update the sermon. |
||
| 52 | * |
||
| 53 | * @param Ministry $user |
||
| 54 | * @param Sermon $sermon |
||
| 55 | * |
||
| 56 | * @return mixed |
||
| 57 | */ |
||
| 58 | public function update(Ministry $user, Sermon $sermon) |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Determine whether the user can delete the sermon. |
||
| 65 | * |
||
| 66 | * @param Ministry $user |
||
| 67 | * @param Sermon $sermon |
||
| 68 | * |
||
| 69 | * @return mixed |
||
| 70 | */ |
||
| 71 | public static function delete(Ministry $user, Sermon $sermon) |
||
| 76 |