Viewing file: FrontController.php (3.48 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Http\Controllers;
use App\Models\Customer;
use App\Models\Domain;
use App\Models\FAQ;
use App\Models\Page;
use App\Models\Plan;
use App\Models\Subscribe;
use App\Models\Template;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
class FrontController extends Controller
{
public function home(Request $request){
if(get_settings('landing_page_status')=='disable'){
return redirect()->route('login');
}
$data['local_setting'] = json_decode(get_settings('local_setting'));
$data['faqs'] = FAQ::where('status', 'active')->get();
$host=$request->getHost();
$domain=Domain::where('host', $host)->first();
if ($domain && $domain->status !='approved'){
echo "<div style='text-align: center; font-weight: 800; color: red; padding: 15rem'><h4>Your domain is not approved, contact with administrator</h4></div>";
return;
}
if ($domain) {
$customer = Customer::find($domain->customer_id);
$data['plans'] = Plan::where('admin_id',$customer->id)->where('status', 'active')->where('added_by', $customer->type)->get();
}else {
$data['plans'] = Plan::where('id', '!=', 1)->where('status', 'active')->where('added_by', 'admin')->where('plan_type', 'normal')->get();
}
return view('front.index',$data);
}
public function aboutUs(){
return view('front.about_us');
}
public function services(){
return view('front.service');
}
public function pricing(Request $request){
$host=$request->getHost();
$domain=Domain::where('host', $host)->where('status', 'approved')->first();
if ($domain) {
$customer = Customer::find($domain->customer_id);
$data['plans'] = Plan::where('admin_id',$customer->id)->where('status', 'active')->where('added_by', $customer->type)->get();
}else {
$data['plans'] = Plan::where('id', '!=', 1)->where('status', 'active')->where('added_by', 'admin')->where('plan_type', 'normal')->get();
}
return view('front.pricing',$data);
}
public function contact(){
return view('front.contact_us');
}
public function page($page){
$data['page'] = Page::where('url',$page)->where('status','published')->firstOrFail();
return view('front.page',$data);
}
public function demo_login(){
return view('front.login_demo');
}
public function verifyCode(Request $request){
$code=$request->purchase_code;
if(!$code){
abort(404);
}
$client = new Client();
$res = $client->request('GET', 'http://verify.picotech.app/verify.php?purchase_code='.$code);
$response= json_decode($res->getBody());
if(isset($response->id) && $response->id){
$data=[
'code'=>$code,
'id'=>$response->id,
'checked_at'=>now()
];
File::put(storage_path().'/framework/build',base64_encode(json_encode($data)));
if($request->verify){
return back();
}
return back()->with('success','Purchase code verified successfully');
}else{
File::delete(storage_path().'/framework/build');
return back()->withErrors(['msg'=>'Invalid purchase code']);
}
}
}
|