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.

41 lines
1.0 KiB
PHTML

<?php
namespace App\Http\Controllers;
1 year ago
use App\Models\Customer;
use App\Models\Setting;
use Illuminate\Http\Request;
1 year ago
use Illuminate\Support\Str;
class HomeController extends Controller
{
public function index()
{
return inertia('Home', [
'app_name' => Setting::where('key', 'app_name')->value('value'),
1 year ago
'customer' => null,
'point' => 0,
]);
}
public function check(Request $request)
{
$request->validate([
'customer_code' => 'required|string|exists:customers,code'
]);
1 year ago
$name = "";
$customer = Customer::where('code', $request->customer_code)->first();
$names = explode(' ', $customer->name);
foreach ($names as $n) {
$name .= Str::mask($n, '*', 3) . ' ';
}
return inertia('Home', [
'app_name' => Setting::where('key', 'app_name')->value('value'),
'customer' => $name,
'point' => $customer->last_point,
'names' => $names
]);
}
}