diff --git a/app/Events/NotificationEvent.php b/app/Events/NotificationEvent.php index d04ee6d..9bee7b2 100644 --- a/app/Events/NotificationEvent.php +++ b/app/Events/NotificationEvent.php @@ -4,8 +4,6 @@ namespace App\Events; use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; -use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/app/Http/Controllers/Admin/CustomerController.php b/app/Http/Controllers/Admin/CustomerController.php index 1406cb2..2908cfb 100644 --- a/app/Http/Controllers/Admin/CustomerController.php +++ b/app/Http/Controllers/Admin/CustomerController.php @@ -115,8 +115,8 @@ class CustomerController extends Controller public function update(Request $request, Customer $customer) { $request->validate([ - 'email' => 'nullable|email|unique:customers,email,' . $customer->id, - 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'email' => 'nullable|email|unique:customers,email,'.$customer->id, + 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,'.$customer->id, 'password' => 'nullable|string|min:8', 'name' => 'required|string', 'fullname' => 'required|string', diff --git a/app/Http/Controllers/Admin/CustomerMitraController.php b/app/Http/Controllers/Admin/CustomerMitraController.php index aab0f66..d945c75 100644 --- a/app/Http/Controllers/Admin/CustomerMitraController.php +++ b/app/Http/Controllers/Admin/CustomerMitraController.php @@ -220,8 +220,8 @@ class CustomerMitraController extends Controller public function update(Request $request, Customer $customer) { $request->validate([ - 'email' => 'nullable|email|unique:customers,email,' . $customer->id, - 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'email' => 'nullable|email|unique:customers,email,'.$customer->id, + 'username' => 'required|string|min:5|alpha_dash|unique:customers,username,'.$customer->id, 'password' => 'nullable|string|min:8', 'name' => 'required|string', 'fullname' => 'required|string', diff --git a/app/Http/Controllers/Admin/GeneralController.php b/app/Http/Controllers/Admin/GeneralController.php index 60982fa..2e51e2a 100644 --- a/app/Http/Controllers/Admin/GeneralController.php +++ b/app/Http/Controllers/Admin/GeneralController.php @@ -103,15 +103,15 @@ class GeneralController extends Controller $date = $date->addDay(); } - $saleYearDepositCharts = Sale::selectRaw("SUM(amount) as sale_total, MONTH(date_time) as month") + $saleYearDepositCharts = Sale::selectRaw('SUM(amount) as sale_total, MONTH(date_time) as month') ->where('payed_with', Sale::PAYED_WITH_DEPOSIT) - ->whereRaw("YEAR(sales.date_time) = " . Carbon::parse($year)->year) - ->groupBy(DB::raw("MONTH(date_time)")); + ->whereRaw('YEAR(sales.date_time) = '.Carbon::parse($year)->year) + ->groupBy(DB::raw('MONTH(date_time)')); - $saleYearPaylaterCharts = Sale::selectRaw("SUM(amount) as sale_total, MONTH(date_time) as month") + $saleYearPaylaterCharts = Sale::selectRaw('SUM(amount) as sale_total, MONTH(date_time) as month') ->where('payed_with', Sale::PAYED_WITH_PAYLATER) - ->whereRaw("YEAR(sales.date_time) = " . Carbon::parse($year)->year) - ->groupBy(DB::raw("MONTH(date_time)")); + ->whereRaw('YEAR(sales.date_time) = '.Carbon::parse($year)->year) + ->groupBy(DB::raw('MONTH(date_time)')); // filter lokasi if ($request->year_location_id != '') { diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index a455c48..80f838e 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -70,9 +70,9 @@ class UserController extends Controller { $request->validate([ 'name' => 'required|string|max:255', - 'email' => 'required|email|unique:users,email,' . $user->id, + 'email' => 'required|email|unique:users,email,'.$user->id, 'password' => 'nullable|string|max:255', - 'username' => 'required|alpha_dash|unique:users,username,' . $user->id, + 'username' => 'required|alpha_dash|unique:users,username,'.$user->id, 'phone_wa' => 'required|string', 'photo' => 'nullable|image', ]); diff --git a/app/Http/Controllers/Customer/AuthController.php b/app/Http/Controllers/Customer/AuthController.php index 2b8f325..eabf23c 100644 --- a/app/Http/Controllers/Customer/AuthController.php +++ b/app/Http/Controllers/Customer/AuthController.php @@ -54,7 +54,7 @@ class AuthController extends Controller } $password = Hash::check($request->password, $user->password); - if (!$password) { + if (! $password) { return redirect()->route('customer.login') ->with('message', ['type' => 'error', 'message' => 'Invalid credentials']); } @@ -109,7 +109,7 @@ class AuthController extends Controller 'fullname' => $user->name, 'name' => $user->name, 'email' => $user->email, - 'username' => Str::slug($user->name . '_' . Str::random(5), '_'), + 'username' => Str::slug($user->name.'_'.Str::random(5), '_'), 'google_id' => $user->id, 'google_oauth_response' => json_encode($user), 'status' => Customer::STATUS_ACTIVE, diff --git a/app/Http/Controllers/Customer/CartController.php b/app/Http/Controllers/Customer/CartController.php index b2adc41..e95fa72 100644 --- a/app/Http/Controllers/Customer/CartController.php +++ b/app/Http/Controllers/Customer/CartController.php @@ -49,7 +49,7 @@ class CartController extends Controller $operator = $request->param ?? 'add'; //delete, sub, add $customer = $request->user('customer'); - if (!$customer->allow_transaction) { + if (! $customer->allow_transaction) { $customer->carts()->delete(); return redirect()->back() diff --git a/app/Http/Controllers/Customer/DepositController.php b/app/Http/Controllers/Customer/DepositController.php index b4f5cde..9b936ec 100644 --- a/app/Http/Controllers/Customer/DepositController.php +++ b/app/Http/Controllers/Customer/DepositController.php @@ -42,7 +42,7 @@ class DepositController extends Controller public function create(Request $request) { $customer = $request->user('customer'); - if (!$customer->allow_transaction) { + if (! $customer->allow_transaction) { return redirect()->back() ->with('message', ['type' => 'error', 'message' => 'akun anda dibekukan tidak dapat melakukan transaksi']); } diff --git a/app/Http/Controllers/Customer/PaylaterController.php b/app/Http/Controllers/Customer/PaylaterController.php index ec5a8e6..a8a4c02 100644 --- a/app/Http/Controllers/Customer/PaylaterController.php +++ b/app/Http/Controllers/Customer/PaylaterController.php @@ -29,7 +29,7 @@ class PaylaterController extends Controller if ($paylater->type == PaylaterHistory::TYPE_REPAYMENT) { $deposit = DepositHistory::where('related_id', $paylater->id)->first(); - if (!in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) { + if (! in_array($deposit->is_valid, [DepositHistory::STATUS_VALID])) { return redirect()->route('transactions.deposit.show', [ 'deposit' => $deposit, 'back' => 'customer.paylater.index', diff --git a/app/Http/Controllers/Customer/ProfileController.php b/app/Http/Controllers/Customer/ProfileController.php index 5ea743f..e77207a 100644 --- a/app/Http/Controllers/Customer/ProfileController.php +++ b/app/Http/Controllers/Customer/ProfileController.php @@ -32,7 +32,7 @@ class ProfileController extends Controller 'name' => 'string|nullable', 'address' => 'string|required', 'phone' => 'string|required|numeric', - 'username' => 'string|required|min:5|alpha_dash|unique:customers,username,' . $customer->id, + 'username' => 'string|required|min:5|alpha_dash|unique:customers,username,'.$customer->id, 'password' => 'nullable|string|min:8|confirmed', 'image' => 'nullable|image', ]); diff --git a/app/Http/Middleware/CustomerApi.php b/app/Http/Middleware/CustomerApi.php index 7cbe4ad..37d7961 100644 --- a/app/Http/Middleware/CustomerApi.php +++ b/app/Http/Middleware/CustomerApi.php @@ -21,6 +21,7 @@ class CustomerApi $customer = Customer::find($request->header('user')); Auth::guard('customer')->setUser($customer); } + return $next($request); } } diff --git a/app/Http/Middleware/CustomerComplateProfile.php b/app/Http/Middleware/CustomerComplateProfile.php index 297ebe5..5ccd013 100644 --- a/app/Http/Middleware/CustomerComplateProfile.php +++ b/app/Http/Middleware/CustomerComplateProfile.php @@ -17,7 +17,7 @@ class CustomerComplateProfile { $customer = $request->user('customer'); - if (!$customer->is_profile_complate) { + if (! $customer->is_profile_complate) { return redirect()->route('customer.profile.show') ->with('message', ['type' => 'error', 'message' => 'silahkan lengkapi profile sebelum dapat ber-transaksi']); } diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index af99697..c6bbd8e 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -4,7 +4,6 @@ namespace App\Http\Middleware; use App\Models\Notification; use Illuminate\Http\Request; -use Illuminate\Notifications\Notification as NotificationsNotification; use Inertia\Middleware; class HandleInertiaRequests extends Middleware @@ -32,6 +31,7 @@ class HandleInertiaRequests extends Middleware public function share(Request $request): array { $notifications = Notification::where('entity_type', \App\Models\User::class)->orderBy('created_at', 'desc'); + return array_merge(parent::share($request), [ 'auth' => [ 'user' => $request->user() ? $request->user()->load(['role.permissions']) : $request->user(), diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 8e657f7..1aaa827 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -145,7 +145,7 @@ class Customer extends Authenticatable return ' - '; } - return '+62' . $this->phone; + return '+62'.$this->phone; }); } diff --git a/app/Models/DepositHistory.php b/app/Models/DepositHistory.php index 207405b..7dde7c3 100644 --- a/app/Models/DepositHistory.php +++ b/app/Models/DepositHistory.php @@ -6,7 +6,6 @@ use App\Events\NotificationEvent; use App\Services\GeneralService; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Support\Carbon; -use PHPUnit\Framework\Error\Notice; class DepositHistory extends Model { @@ -101,10 +100,10 @@ class DepositHistory extends Model { return Attribute::make(get: function () { if ($this->credit == 0) { - return 'Rp ' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); + return 'Rp '.number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); } - return '-Rp ' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); + return '-Rp '.number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); }); } @@ -172,7 +171,7 @@ class DepositHistory extends Model $notification = Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan deposit transfer manual sebesar : ' . $this->amount . $status, + 'description' => $this->customer->fullname.' melakukan deposit transfer manual sebesar : '.$this->amount.$status, 'url' => route('deposit.edit', $this), 'type' => Notification::TYPE_DEPOSIT, ]); @@ -186,7 +185,7 @@ class DepositHistory extends Model $notification = Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan deposit manual sebesar : ' . $this->amount . $status, + 'description' => $this->customer->fullname.' melakukan deposit manual sebesar : '.$this->amount.$status, 'url' => route('deposit.edit', $this), 'type' => Notification::TYPE_DEPOSIT, ]); @@ -195,13 +194,12 @@ class DepositHistory extends Model if ($this->payment_channel == Setting::PAYMENT_MIDTRANS) { $notification = Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan deposit via midtrans sebesar : ' . $this->amount, + 'description' => $this->customer->fullname.' melakukan deposit via midtrans sebesar : '.$this->amount, 'url' => route('deposit.edit', $this), 'type' => Notification::TYPE_DEPOSIT, ]); } - NotificationEvent::dispatch([ 'id' => $notification->id, 'description' => $notification->description, @@ -224,7 +222,7 @@ class DepositHistory extends Model $notification = Notification::create([ 'entity_type' => User::class, - 'description' => $this->customer->fullname . ' melakukan pembayaran hutang sebesar ' . $this->amount, + 'description' => $this->customer->fullname.' melakukan pembayaran hutang sebesar '.$this->amount, 'url' => route('paylater.repay.edit', $this), 'type' => Notification::TYPE_DEPOSIT, ]); @@ -247,7 +245,7 @@ class DepositHistory extends Model { Notification::create([ 'entity_id' => $this->customer_id, - 'description' => 'Deposit ' . $this->description . ' sebesar ' . $this->amount . ' sudah sukses diterima', + 'description' => 'Deposit '.$this->description.' sebesar '.$this->amount.' sudah sukses diterima', ]); } } diff --git a/app/Models/PaylaterHistory.php b/app/Models/PaylaterHistory.php index 355e721..0ecec7a 100644 --- a/app/Models/PaylaterHistory.php +++ b/app/Models/PaylaterHistory.php @@ -73,10 +73,10 @@ class PaylaterHistory extends Model { return Attribute::make(get: function () { if ($this->credit == 0) { - return 'Rp ' . number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); + return 'Rp '.number_format($this->debit, is_float($this->debit) ? 2 : 0, ',', '.'); } - return '-Rp ' . number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); + return '-Rp '.number_format($this->credit, is_float($this->credit) ? 2 : 0, ',', '.'); }); } @@ -118,7 +118,7 @@ class PaylaterHistory extends Model { Notification::create([ 'entity_id' => $this->customer_id, - 'description' => 'Pembayaran ' . $this->description . ' sebesar ' . $this->amount . ' sudah sukses diterima', + 'description' => 'Pembayaran '.$this->description.' sebesar '.$this->amount.' sudah sukses diterima', ]); } diff --git a/app/Models/SaleItem.php b/app/Models/SaleItem.php index b0e952b..723a16d 100644 --- a/app/Models/SaleItem.php +++ b/app/Models/SaleItem.php @@ -38,7 +38,7 @@ class SaleItem extends Model { return Attribute::make(get: function () { $shareText = Setting::getByKey('SHARE_TEXT').' -Kode Voucher : ' . $this->voucher->username; +Kode Voucher : '.$this->voucher->username; return $shareText; }); diff --git a/app/Models/Voucher.php b/app/Models/Voucher.php index c9a06b0..2b8f999 100644 --- a/app/Models/Voucher.php +++ b/app/Models/Voucher.php @@ -176,7 +176,7 @@ class Voucher extends Model if ($count <= $treshold) { $notification = Notification::create([ 'entity_type' => User::class, - 'description' => 'stok voucher ' . $this->locationProfile->name . ' (' . $this->locationProfile->location->name . ') ' . ' tersisa : ' . $count, + 'description' => 'stok voucher '.$this->locationProfile->name.' ('.$this->locationProfile->location->name.') '.' tersisa : '.$count, 'url' => route('voucher.profile', $this->locationProfile->location_id), 'type' => Notification::TYPE_VOUCHER_STOCK, ]); diff --git a/config/broadcasting.php b/config/broadcasting.php index 81d09d1..11ee2b7 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,7 +36,7 @@ return [ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - 'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com', + 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'port' => env('PUSHER_PORT', 443), 'scheme' => env('PUSHER_SCHEME', 'https'), 'encrypted' => false, diff --git a/database/seeders/DummySeeder.php b/database/seeders/DummySeeder.php index 34804c7..8fdfa40 100644 --- a/database/seeders/DummySeeder.php +++ b/database/seeders/DummySeeder.php @@ -49,8 +49,8 @@ class DummySeeder extends Seeder $images = ['1.webp', '2.webp', '3.webp']; foreach ($images as $index => $image) { Banner::create([ - 'title' => 'Banner ' . $index, - 'image' => 'sample/' . $image, + 'title' => 'Banner '.$index, + 'image' => 'sample/'.$image, 'description' => '