You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers;
use http\Header;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Yz;
class ViewController extends Controller
{
public function site()
{
$domain = request()->getHost();
$site = DB::table('site_organization')
->where('domain', 'like', "%\"$domain\"%")
->where('status', 1)
->where('is_del', 0)
->first();
if (!$site) return false;
return $site;
}
public function home()
{
$site = self::site();
if (!$site) return '站点暂时关闭';
$hospital_ids = json_decode($site->hospital, true);
$combos = DB::table('combos')
->whereIn('hospital_id', $hospital_ids)
->limit(8)
->get();
foreach ($combos as $combo) {
$combo->tags_arr = json_decode($combo->tags, true);
}
return view('home.home', [
'combos' => $combos
]);
}
public function combo(Request $request)
{
$site = self::site();
if (!$site) return '站点暂时关闭';
$hospital_ids = json_decode($site->hospital, true);
$combo_id = $request->get('id');
$combo = DB::table('combos')
->where('id', $combo_id)
->whereIn('hospital_id', $hospital_ids)
->first();
$combo->items_data = json_decode($combo->items, true);
$hospital = DB::table('hospital')
->where('id', $combo->hospital_id)
->first();
$url = $hospital->mp_jump . '?combo=' . $combo->combo_id . '&hospital=' . $hospital->code;
return view('combo.combo', [
'qrcode' => $url,
'combo' => $combo,
'hospital' => $hospital,
]);
}
}