Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
69.23% covered (warning)
69.23%
9 / 13
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Constants
69.23% covered (warning)
69.23%
9 / 13
0.00% covered (danger)
0.00%
0 / 2
5.73
0.00% covered (danger)
0.00%
0 / 1
 getPromptQuotaForPlan
75.00% covered (warning)
75.00%
9 / 12
0.00% covered (danger)
0.00%
0 / 1
4.25
 clearPlanQuotaCache
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Helpers;
4
5use App\Http\Models\Plans;
6use Illuminate\Support\Facades\Cache;
7
8abstract class Constants
9{
10    /**
11     * Default prompt quota values (fallback when database is not available).
12     *
13     * @deprecated Use getPromptQuotaForPlan() for database-driven values
14     */
15    public const FLYWRITE_LINKEDIN_COMMENTS_FREEMIUM_PROMPT_QUOTA_TOTAL = 5;
16
17    public const FLYWRITE_LINKEDIN_COMMENTS_STARTER_PROMPT_QUOTA_TOTAL = 10;
18
19    public const FLYWRITE_LINKEDIN_COMMENTS_GROWTH_PROMPT_QUOTA_TOTAL = 30;
20
21    public const FLYWRITE_LINKEDIN_COMMENTS_SALESPRO_PROMPT_QUOTA_TOTAL = 70;
22
23    public const PROPLANTEAMSSMB = 130;
24
25    public const PROPLANTEAMSENT = 250;
26
27    public const DONOT_INCLUDE_INSTRUCTIONS_TO_CONTINUE = 'Do not include any of these responses or any variations of it. Responses: ';
28
29    /**
30     * Legacy hardcoded plan quotas.
31     *
32     * @deprecated Use getPromptQuotaForPlan() for database-driven values
33     */
34    public const CURRENT_SUBSCRIPTION_PLAN_IDENTIFIERS = [
35        'freemium' => self::FLYWRITE_LINKEDIN_COMMENTS_FREEMIUM_PROMPT_QUOTA_TOTAL,
36        'starter' => self::FLYWRITE_LINKEDIN_COMMENTS_STARTER_PROMPT_QUOTA_TOTAL,
37        'growth' => self::FLYWRITE_LINKEDIN_COMMENTS_GROWTH_PROMPT_QUOTA_TOTAL,
38        'appsumo-growth-lifetime' => self::FLYWRITE_LINKEDIN_COMMENTS_GROWTH_PROMPT_QUOTA_TOTAL,
39        'sales-pro-yearly' => self::FLYWRITE_LINKEDIN_COMMENTS_SALESPRO_PROMPT_QUOTA_TOTAL,
40        'starter-yearly' => self::FLYWRITE_LINKEDIN_COMMENTS_STARTER_PROMPT_QUOTA_TOTAL,
41        'growth-yearly' => self::FLYWRITE_LINKEDIN_COMMENTS_GROWTH_PROMPT_QUOTA_TOTAL,
42        'sales-pro-monthly' => self::FLYWRITE_LINKEDIN_COMMENTS_SALESPRO_PROMPT_QUOTA_TOTAL,
43        'dealfuel-growth-lifetime' => self::FLYWRITE_LINKEDIN_COMMENTS_GROWTH_PROMPT_QUOTA_TOTAL,
44        'pro-plan-teams-smb' => self::PROPLANTEAMSSMB,
45        'pro-plan-teams-ent' => self::PROPLANTEAMSENT,
46    ];
47
48    /**
49     * Get the prompt quota for a plan from the database.
50     *
51     * This method provides database-driven prompt quotas with caching.
52     * Falls back to hardcoded values if the plan is not found.
53     *
54     * @param  string  $identifier  The plan identifier
55     * @return int The prompt quota for the plan
56     */
57    public static function getPromptQuotaForPlan(string $identifier): int
58    {
59        return Cache::remember("plan_quota_{$identifier}", 3600, function () use ($identifier) {
60            $plan = Plans::where('identifier', $identifier)
61                ->whereNull('pricing_version')
62                ->first();
63
64            if ($plan) {
65                // First try the getPlanFeatureValue method for database-driven value
66                $value = $plan->getPlanFeatureValue('prompts_per_day');
67                if ($value !== null) {
68                    return (int) $value;
69                }
70
71                // Fallback to plan-level attribute
72                if ($plan->prompts_per_day !== null) {
73                    return (int) $plan->prompts_per_day;
74                }
75            }
76
77            // Final fallback to hardcoded values
78            return self::CURRENT_SUBSCRIPTION_PLAN_IDENTIFIERS[$identifier] ?? 5;
79        });
80    }
81
82    /**
83     * Clear the cached quota for a plan.
84     *
85     * @param  string  $identifier  The plan identifier
86     */
87    public static function clearPlanQuotaCache(string $identifier): void
88    {
89        Cache::forget("plan_quota_{$identifier}");
90    }
91
92    const DEFAULT_OPTIMISTIC_PROMPT = 'Write a positive, optimistic, and encouraging response to this LinkedIn post. Output should be crisp and clear. Write in a way that can go viral on LinkedIn. Include a hashtag and emojis.';
93
94    const DEFAULT_CURIOUS_PROMPT = 'Write a curious and engaging reply to this LinkedIn post. Output should be crisp and clear. Write in a way that can go viral on LinkedIn. Include a hashtag and emojis. Include a question to solicit engagement with the author where appropriate and applicable.';
95
96    const DEFAULT_THOUGHTFUL_PROMPT = 'Write a thoughtful, inspiring, and reflective response to this LinkedIn post. Output should be crisp and clear. Write in a way that can go viral on LinkedIn. Include a hashtag and emojis.';
97
98    const DEFAULT_CUSTOM_PROMPT = '**ADD YOUR PROMPT INSTRUCTIONS HERE**';
99
100    const DEFAULT_FLYENGAGE_PROMPTS = [
101        'curious' => self::DEFAULT_CURIOUS_PROMPT,
102        'optimistic' => self::DEFAULT_OPTIMISTIC_PROMPT,
103        'thoughtful' => self::DEFAULT_THOUGHTFUL_PROMPT,
104        'custom' => self::DEFAULT_CUSTOM_PROMPT,
105    ];
106
107    const DEFAULT_FLYPOST_HIRING_PROMPT = 'Write a LinkedIn template post about hiring for a **INSERTROLE**. Output should be creative and clear. Write in a way that can go viral on LinkedIn.';
108
109    const DEFAULT_FLYPOST_CELEBRATE_SOMETHING_PROMPT = 'Write a LinkedIn template post for celebrating a **PERSONAL/EMPLOYEE** milestone about **GIVING KUDOS TO [INSERTNAME] FOR [INSERT THE KUDO], A PROJECT LAUNCH, A WORK ANNIVERSARY, A NEW POSITION, A NEW EDUCATIONAL MILESTONE, OR A NEW CERTIFICATION**. Output should be crisp and clear. Write in a way that can go viral on LinkedIn. Include emojis and hashtags.';
110
111    const DEFAULT_FLYPOST_COMPANY_NEWS_PROMPT = 'Write an insightful LinkedIn template post about a Company Update for **NEW PRODUCT RELEASE, NEW PRESS RELEASE ISSUED, FUNDRAISING MILESTONE, NEW C-SUITE PERSONNEL, ACHIEVING A REVENUE MILESTONE, HOSTING LIVE EVENT OR WEBINAR, OR SPONSORING AN EVENT**. Output should be creative and clear. Write in a way that can go viral on LinkedIn. Include emojis and hashtags.';
112
113    const DEFAULT_FLYPOST_THOUGHT_LEADERSHIP_PROMPT = 'Write an insightful LinkedIn social media post for thought leadership about **INSERTTOPIC**. Output should be creative and clear. Write in a way that can go viral on LinkedIn. Include emojis and hashtags.';
114
115    const DEFAULT_FLYPOST_CUSTOM_PROMPT = 'Write a LinkedIn post about **ADD YOUR PROMPT INSTRUCTIONS HERE**.';
116
117    const DEFAULT_FLYPOST_PROMPTS = [
118        'thought leadership' => self::DEFAULT_FLYPOST_THOUGHT_LEADERSHIP_PROMPT,
119        'company news' => self::DEFAULT_FLYPOST_COMPANY_NEWS_PROMPT,
120        'celebrate something' => self::DEFAULT_FLYPOST_CELEBRATE_SOMETHING_PROMPT,
121        'hiring' => self::DEFAULT_FLYPOST_HIRING_PROMPT,
122        'custom' => self::DEFAULT_FLYPOST_CUSTOM_PROMPT,
123    ];
124
125    const FLYPOST_FE_TYPING_SPEED_PER_MINUTE = 60;
126
127    const FLYENGAGE_FE_TYPING_SPEED_PER_MINUTE = 50;
128
129    const ADMIN_CENTER_USERS_TABLE_REPORTING_TABLE_HEADERS = [
130        [
131            'key' => 'first_name',
132            'value' => 'First Name',
133            'checked' => true,
134        ],
135        [
136            'key' => 'last_name',
137            'value' => 'Last Name',
138            'checked' => true,
139        ],
140        [
141            'key' => 'email',
142            'value' => 'Email',
143            'checked' => true,
144        ],
145        [
146            'key' => 'license_type',
147            'value' => 'License Type',
148            'checked' => true,
149        ],
150        [
151            'key' => 'flymsg_account_creation_date',
152            'value' => 'FlyMSG Account Creation Date',
153            'checked' => true,
154        ],
155        [
156            'key' => 'is_the_user_signed_into_flymsg_extension',
157            'value' => 'Is the User Signed into FlyMSG Extension?',
158            'checked' => true,
159        ],
160        [
161            'key' => 'extension_installed_on_any_browser',
162            'value' => 'Extension Installed on Any Browser',
163            'checked' => true,
164        ],
165        [
166            'key' => 'last_login_to_flylearning',
167            'value' => 'Last Login to FlyLearning',
168            'checked' => true,
169        ],
170        [
171            'key' => 'last_login_to_flymsg',
172            'value' => 'Last Login to FlyMSG',
173            'checked' => true,
174        ],
175        [
176            'key' => 'total_no_of_characters_typed_by_flymsg_by_user',
177            'value' => 'Total # of Characters Typed by FlyMSG by User',
178            'checked' => true,
179        ],
180        [
181            'key' => 'total_no_of_characters_typed_summarized_monthly_by_flymsg_by_user',
182            'value' => 'Total # of Characters Typed Summarized Monthly by FlyMSG by User',
183            'checked' => true,
184        ],
185        [
186            'key' => 'total_time_saved_by_flymsg_by_user',
187            'value' => 'Total Time Saved by FlyMSG by User',
188            'checked' => true,
189        ],
190        [
191            'key' => 'total_cost_savings_by_flymsg_by_user',
192            'value' => 'Total Cost Savings by FlyMSG by User',
193            'checked' => true,
194        ],
195        [
196            'key' => 'last_date_user_used_a_flycut',
197            'value' => 'Last Date User Used a FlyCut',
198            'checked' => true,
199        ],
200        [
201            'key' => 'flycuts_created_count',
202            'value' => '# of FlyCuts Created (Count)',
203            'checked' => true,
204        ],
205        [
206            'key' => 'flycuts_created_last_date',
207            'value' => '# of FlyCuts Created (Last Date)',
208            'checked' => true,
209        ],
210        [
211            'key' => 'flyplates_added_to_flycuts_count',
212            'value' => '# of FlyPlates Added to FlyCuts (Count)',
213            'checked' => true,
214        ],
215        [
216            'key' => 'flyplates_added_to_flycuts_last_date',
217            'value' => '# of FlyPlates Added to FlyCuts (Last Date)',
218            'checked' => true,
219        ],
220        [
221            'key' => 'total_no_of_times_flyengage_ai_used_count',
222            'value' => 'Total # of Times FlyEngage AI Used (Count)',
223            'checked' => true,
224        ],
225        [
226            'key' => 'total_no_of_characters_typed_by_flyengage',
227            'value' => 'Total # of Characters Typed by FlyEngage',
228            'checked' => true,
229        ],
230        [
231            'key' => 'total_no_of_times_flyposts_used_count',
232            'value' => 'Total # of Times FlyPosts Used (Count)',
233            'checked' => true,
234        ],
235        [
236            'key' => 'total_no_of_characters_typed_by_flyposts',
237            'value' => 'Total # of Characters Typed by FlyPosts',
238            'checked' => true,
239        ],
240        [
241            'key' => 'which_browser_has_an_extension_been_installed_on',
242            'value' => 'Which Browser has an extension been installed on',
243            'checked' => true,
244        ],
245        [
246            'key' => 'flymsg_chrome_extension_installed',
247            'value' => 'FlyMSG Chrome Extension Installed',
248            'checked' => true,
249        ],
250        [
251            'key' => 'flymsg_chrome_extension_installed_date',
252            'value' => 'FlyMSG Chrome Extension Installed (Date)',
253            'checked' => true,
254        ],
255        [
256            'key' => 'flymsg_chrome_extension_uninstalled',
257            'value' => 'FlyMSG Chrome Extension UNInstalled',
258            'checked' => true,
259        ],
260        [
261            'key' => 'flymsg_chrome_extension_uninstalled_date',
262            'value' => 'FlyMSG Chrome Extension UNInstalled (Date)',
263            'checked' => true,
264        ],
265        [
266            'key' => 'flymsg_edge_extension_installed',
267            'value' => 'FlyMSG Edge Extension Installed',
268            'checked' => true,
269        ],
270        [
271            'key' => 'flymsg_edge_extension_installed_date',
272            'value' => 'FlyMSG Edge Extension Installed (Date)',
273            'checked' => true,
274        ],
275        [
276            'key' => 'flymsg_edge_extension_uninstalled',
277            'value' => 'FlyMSG Edge Extension UNInstalled',
278            'checked' => true,
279        ],
280        [
281            'key' => 'flymsg_edge_extension_uninstalled_date',
282            'value' => 'FlyMSG Edge Extension UNInstalled (Date)',
283            'checked' => true,
284        ],
285        [
286            'key' => 'other_reason_to_sign_out_free_form_field',
287            'value' => '"Other" Reason to sign out (Free form field)',
288            'checked' => true,
289        ],
290        [
291            'key' => 'flymsg_extension_version_for_edge',
292            'value' => 'FlyMSG Extension Version for Edge',
293            'checked' => true,
294        ],
295        [
296            'key' => 'clicked_help_request_help_from_menu_count',
297            'value' => 'Clicked Help/request Help From Menu (Count)',
298            'checked' => true,
299        ],
300        [
301            'key' => 'typed_words_per_minute',
302            'value' => 'Typed Words Per Minute',
303            'checked' => true,
304        ],
305    ];
306}