File size: 5,571 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | <?php
namespace App\Http\Controllers;
use App\Models\Blog;
use App\Models\Clients;
use App\Models\CustomSettings;
use App\Models\Faq;
use App\Models\FrontendForWho;
use App\Models\FrontendFuture;
use App\Models\FrontendGenerators;
use App\Models\FrontendSectionsStatusses;
use App\Models\FrontendTools;
use App\Models\HowitWorks;
use App\Models\OpenAIGenerator;
use App\Models\OpenaiGeneratorFilter;
use App\Models\PaymentPlans;
use App\Models\Setting;
use App\Models\SettingTwo;
use App\Models\Testimonials;
use Exception;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
class IndexController extends Controller
{
public function index()
{
$maintenance = cache()->get('maintenance');
$maintenanceMode = data_get($maintenance, 'maintenance_mode', false);
$maintenanceModeAuth = true;
if (Auth::check()) {
$maintenanceModeAuth = ! Auth::user()->isAdmin();
}
if ($maintenanceMode && $maintenanceModeAuth) {
return view('maintenance.index', ['data' => $maintenance]);
}
$filters = OpenaiGeneratorFilter::all();
$templates = OpenAIGenerator::all();
$plansSubscription = PaymentPlans::where('type', 'subscription')->get()->sortBy('price');
$plansSubscriptionMonthly = PaymentPlans::where([['type', '=', 'subscription'], ['frequency', '=', 'monthly']])->get()->sortBy('price');
$plansSubscriptionLifetime = PaymentPlans::where('type', '=', 'subscription')
->where(function ($query) {
$query->where('frequency', '=', 'lifetime_yearly')
->orWhere('frequency', '=', 'lifetime_monthly');
})
->get()->sortBy('price');
$plansSubscriptionAnnual = PaymentPlans::where([['type', '=', 'subscription'], ['frequency', '=', 'yearly']])->get()->sortBy('price');
$plansPrepaid = PaymentPlans::where('type', 'prepaid')->get()->sortBy('price');
$faq = Faq::all();
$tools = FrontendTools::all();
$futures = FrontendFuture::all();
$testimonials = Testimonials::all();
$howitWorks = HowitWorks::orderBy('order', 'ASC')->limit(3)->get();
$howitWorksDefaults = self::howitWorksDefaults();
$clients = Clients::all();
$who_is_for = FrontendForWho::all();
$generatorsList = FrontendGenerators::orderBy('created_at', 'desc')->get();
$posts = Blog::where('status', 1)->orderBy('id', 'desc')->paginate(FrontendSectionsStatusses::first()->blog_posts_per_page ?? 3);
$setting = Setting::first();
if ($setting->frontend_additional_url != null) {
return Redirect::to($setting->frontend_additional_url);
}
$currency = currency()->symbol;
return view('index', compact(
'templates',
'plansPrepaid',
'plansSubscription',
'filters',
'faq',
'tools',
'testimonials',
'howitWorks',
'howitWorksDefaults',
'clients',
'futures',
'who_is_for',
'generatorsList',
'plansSubscriptionMonthly',
'plansSubscriptionLifetime',
'plansSubscriptionAnnual',
'posts',
'currency'
));
}
public function activate(Request $request)
{
cache()->forget('check_license_domain_' . $request->getHost());
$valid = $request->liquid_license_status;
$liquid_license_domain_key = $request->liquid_license_domain_key;
if ($valid == 'valid') {
$client = new Client;
try {
$response = $client->request('GET', 'https://portal.liquid-themes.com/api/license/' . $liquid_license_domain_key);
} catch (Exception $e) {
return response()->json(['status' => 'error', 'message' => $e->getMessage()]);
}
$settings_two = SettingTwo::first();
// $setting->stripe_status_for_now = 'active';
$settings_two->liquid_license_domain_key = $liquid_license_domain_key;
$settings_two->liquid_license_type = json_decode($response->getBody())->licenseType;
$settings_two->save();
return redirect()->route('dashboard.index');
} else {
echo 'Activation failed!';
}
}
public function howitWorksDefaults()
{
$values = json_decode('{"option": TRUE, "html": ""}');
$default_html = 'Want to see? <a class="text-[#FCA7FF]" href="https://codecanyon.net/item/magicai-openai-content-text-image-chat-code-generator-as-saas/45408109" target="_blank">' . __('Join') . ' Magic</a>';
//Check display bottom line
$bottomline = CustomSettings::where('key', 'howitworks_bottomline')->first();
if ($bottomline != null) {
$values['option'] = $bottomline->value_int ?? 1;
$values['html'] = $bottomline->value_html ?? $default_html;
} else {
$bottomline = new CustomSettings;
$bottomline->key = 'howitworks_bottomline';
$bottomline->title = 'Used in How it Works section bottom line. Controls visibility and HTML value of line.';
$bottomline->value_int = 1;
$bottomline->value_html = $default_html;
$bottomline->save();
$values['option'] = 1;
$values['html'] = $default_html;
}
return $values;
}
}
|