Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SocialMediaController | |
0.00% |
0 / 31 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| save | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers; |
| 4 | |
| 5 | use App\Models\SocialSetting; |
| 6 | use Illuminate\Http\Request; |
| 7 | |
| 8 | class SocialMediaController extends Controller |
| 9 | { |
| 10 | public function index() |
| 11 | { |
| 12 | return view('admin.configuration.social-media'); |
| 13 | } |
| 14 | |
| 15 | public function save(Request $request) |
| 16 | { |
| 17 | $fields = [ |
| 18 | // Existing social fields |
| 19 | 'fb_pixel_id', |
| 20 | 'fb_app_id', |
| 21 | 'fb_page_id', |
| 22 | 'fb_bm_id', |
| 23 | 'fb_access_token', |
| 24 | 'wa_number', |
| 25 | 'wa_message', |
| 26 | 'ig_username', |
| 27 | 'ig_url', |
| 28 | 'tiktok_pixel_id', |
| 29 | 'tiktok_url', |
| 30 | |
| 31 | // AI Chatbot settings |
| 32 | 'ai_provider', |
| 33 | 'ai_api_key', |
| 34 | 'ai_model', |
| 35 | 'ai_system_prompt', |
| 36 | |
| 37 | // Facebook Messenger chatbot |
| 38 | 'fb_messenger_token', |
| 39 | 'fb_verify_token', |
| 40 | // BUG FIX: FacebookMessengerService::verifySignature() has always |
| 41 | // read 'fb_app_secret' to verify webhook signatures, but this |
| 42 | // field was never actually collected anywhere on this settings |
| 43 | // page — so it could never be set, and verification silently |
| 44 | // stayed in skip-mode forever. Now it can actually be saved. |
| 45 | 'fb_app_secret', |
| 46 | |
| 47 | // WhatsApp Cloud API |
| 48 | 'wa_cloud_api_token', |
| 49 | 'wa_phone_number_id', |
| 50 | 'wa_verify_token', |
| 51 | // Same bug, same fix, for WhatsAppService::verifySignature(). |
| 52 | 'wa_app_secret', |
| 53 | ]; |
| 54 | |
| 55 | foreach ($fields as $field) { |
| 56 | SocialSetting::setSetting($field, $request->input($field, '')); |
| 57 | } |
| 58 | |
| 59 | // Toggle fields (checkboxes) — save 0 or 1 |
| 60 | SocialSetting::setSetting('chatbot_enabled', $request->has('chatbot_enabled') ? 1 : 0); |
| 61 | SocialSetting::setSetting('fb_messenger_enabled', $request->has('fb_messenger_enabled') ? 1 : 0); |
| 62 | SocialSetting::setSetting('wa_enabled', $request->has('wa_enabled') ? 1 : 0); |
| 63 | |
| 64 | return redirect()->back()->with('success', 'Settings সফলভাবে সেভ হয়েছে!'); |
| 65 | } |
| 66 | } |