22
33namespace Kirschbaum \Commentions \Filament \Concerns ;
44
5+ use Closure ;
56use Illuminate \Database \Eloquent \Model ;
67use Kirschbaum \Commentions \Config ;
78use Kirschbaum \Commentions \Contracts \Commenter ;
8- use Closure ;
99
1010trait HasSidebar
1111{
@@ -60,6 +60,48 @@ public function showSubscribers(): bool
6060 return $ this ->showSubscribers ;
6161 }
6262
63+ public function subscribeLabel (Closure |string $ label ): static
64+ {
65+ $ this ->subscribeLabelOverride = $ label ;
66+
67+ return $ this ;
68+ }
69+
70+ public function unsubscribeLabel (Closure |string $ label ): static
71+ {
72+ $ this ->unsubscribeLabelOverride = $ label ;
73+
74+ return $ this ;
75+ }
76+
77+ public function subscribeIcon (Closure |string $ icon ): static
78+ {
79+ $ this ->subscribeIconOverride = $ icon ;
80+
81+ return $ this ;
82+ }
83+
84+ public function unsubscribeIcon (Closure |string $ icon ): static
85+ {
86+ $ this ->unsubscribeIconOverride = $ icon ;
87+
88+ return $ this ;
89+ }
90+
91+ public function subscribeColor (Closure |string $ color , string $ context = 'action ' ): static
92+ {
93+ $ this ->subscriptionColorOverrides [$ context ]['subscribe ' ] = $ color ;
94+
95+ return $ this ;
96+ }
97+
98+ public function unsubscribeColor (Closure |string $ color , string $ context = 'action ' ): static
99+ {
100+ $ this ->subscriptionColorOverrides [$ context ]['unsubscribe ' ] = $ color ;
101+
102+ return $ this ;
103+ }
104+
63105 protected function resolveCurrentUser (): ?Commenter
64106 {
65107 return Config::resolveAuthenticatedUser ();
@@ -110,50 +152,8 @@ protected function computeSubscriptionColor(Model $record, string $context = 'ac
110152 return $ this ->evaluateSubscriptionOverride ($ this ->subscriptionColorOverrides [$ context ]['subscribe ' ] ?? null , $ record ) ?? ($ context === 'table ' ? 'primary ' : 'gray ' );
111153 }
112154
113- public function subscribeLabel (Closure |string $ label ): static
114- {
115- $ this ->subscribeLabelOverride = $ label ;
116-
117- return $ this ;
118- }
119-
120- public function unsubscribeLabel (Closure |string $ label ): static
121- {
122- $ this ->unsubscribeLabelOverride = $ label ;
123-
124- return $ this ;
125- }
126-
127- public function subscribeIcon (Closure |string $ icon ): static
128- {
129- $ this ->subscribeIconOverride = $ icon ;
130-
131- return $ this ;
132- }
133-
134- public function unsubscribeIcon (Closure |string $ icon ): static
135- {
136- $ this ->unsubscribeIconOverride = $ icon ;
137-
138- return $ this ;
139- }
140-
141- public function subscribeColor (Closure |string $ color , string $ context = 'action ' ): static
142- {
143- $ this ->subscriptionColorOverrides [$ context ]['subscribe ' ] = $ color ;
144-
145- return $ this ;
146- }
147-
148- public function unsubscribeColor (Closure |string $ color , string $ context = 'action ' ): static
149- {
150- $ this ->subscriptionColorOverrides [$ context ]['unsubscribe ' ] = $ color ;
151-
152- return $ this ;
153- }
154-
155155 /**
156- * @param (Closure(Model): string)|string|null $override
156+ * @param (Closure(Model): string)|string|null $override
157157 */
158158 protected function evaluateSubscriptionOverride (Closure |string |null $ override , Model $ record ): ?string
159159 {
@@ -164,10 +164,6 @@ protected function evaluateSubscriptionOverride(Closure|string|null $override, M
164164 return $ override ;
165165 }
166166
167- /**
168- *
169- * @return bool|null
170- */
171167 protected function toggleSubscriptionForRecord (Model $ record ): ?bool
172168 {
173169 $ user = $ this ->resolveCurrentUser ();
0 commit comments