Muhammad Iqbal Afandi преди 3 години
родител
ревизия
89a4580db4

+ 0
- 1
app/Http/Controllers/CustomerController.php Целия файл

@@ -2,7 +2,6 @@
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
-use App\Models\Sale;
6 5
 use App\Models\Customer;
7 6
 use App\Http\Requests\Customer\StoreCustomerRequest;
8 7
 use App\Http\Requests\Customer\UpdateCustomerRequest;

+ 10
- 0
app/Http/Controllers/PurchaseController.php Целия файл

@@ -16,6 +16,8 @@ use Illuminate\Database\QueryException;
16 16
 use App\Http\Requests\Purchase\StorePurchaseRequest;
17 17
 use App\Http\Requests\Purchase\UpdatePurchaseRequest;
18 18
 use App\Models\Company;
19
+use App\Models\User;
20
+use App\Policies\PurchasePolicy;
19 21
 use App\Services\FunctionService;
20 22
 use App\Services\PurchaseService;
21 23
 
@@ -330,6 +332,8 @@ class PurchaseController extends Controller
330 332
 
331 333
     public function invoice(Purchase $purchase)
332 334
     {
335
+        $this->authorize("viewAny", Purchase::class);
336
+
333 337
         $ppn = Ppn::first()->ppn;
334 338
 
335 339
         $company = Company::first();
@@ -344,6 +348,8 @@ class PurchaseController extends Controller
344 348
 
345 349
     public function deliveryOrder(Purchase $purchase)
346 350
     {
351
+        $this->authorize("viewAny", Purchase::class);
352
+
347 353
         $company = Company::first();
348 354
 
349 355
         $pdf = Pdf::loadView(
@@ -358,6 +364,8 @@ class PurchaseController extends Controller
358 364
 
359 365
     public function report()
360 366
     {
367
+        $this->authorize("viewAny", User::class);
368
+
361 369
         return inertia("Purchases/Report", [
362 370
             "initialFilters" => request()->only(
363 371
                 "start_date",
@@ -385,6 +393,8 @@ class PurchaseController extends Controller
385 393
 
386 394
     public function reportExcel()
387 395
     {
396
+        $this->authorize("viewAny", User::class);
397
+
388 398
         return new PurchaseDetailsExport([
389 399
             "purchases" => PurchaseDetail::filter(
390 400
                 request()->only("start_date", "end_date", "status")

+ 8
- 0
app/Http/Controllers/SalesController.php Целия файл

@@ -206,6 +206,8 @@ class SalesController extends Controller
206 206
 
207 207
     public function invoice(Sale $sale)
208 208
     {
209
+        $this->authorize("viewAny", Sale::class);
210
+
209 211
         $ppn = Ppn::first()->ppn;
210 212
 
211 213
         $company = Company::first();
@@ -220,6 +222,8 @@ class SalesController extends Controller
220 222
 
221 223
     public function deliveryOrder(Sale $sale)
222 224
     {
225
+        $this->authorize("viewAny", Sale::class);
226
+
223 227
         $company = Company::first();
224 228
 
225 229
         $pdf = Pdf::loadView("PDF.Sales.Do", compact("sale", "company"));
@@ -231,6 +235,8 @@ class SalesController extends Controller
231 235
 
232 236
     public function report()
233 237
     {
238
+        $this->authorize("viewAny", User::class);
239
+
234 240
         return inertia("Sales/Report", [
235 241
             "initialFilters" => request()->only("start_date", "end_date"),
236 242
             "sales" => SaleDetail::filter(
@@ -254,6 +260,8 @@ class SalesController extends Controller
254 260
 
255 261
     public function reportExcel()
256 262
     {
263
+        $this->authorize("viewAny", User::class);
264
+
257 265
         return new SaleDetailsExport([
258 266
             "sales" => SaleDetail::filter(
259 267
                 request()->only("start_date", "end_date")

+ 2
- 0
app/Http/Controllers/SettingController.php Целия файл

@@ -15,6 +15,8 @@ class SettingController extends Controller
15 15
      */
16 16
     public function index()
17 17
     {
18
+        $this->authorize("viewAny", User::class);
19
+
18 20
         return inertia("Settings/Index", [
19 21
             "ppn" => Ppn::first(),
20 22
             "company" => Company::first(),

+ 0
- 94
app/Policies/ReportPolicy.php Целия файл

@@ -1,94 +0,0 @@
1
-<?php
2
-
3
-namespace App\Policies;
4
-
5
-use App\Models\Report;
6
-use App\Models\User;
7
-use Illuminate\Auth\Access\HandlesAuthorization;
8
-
9
-class ReportPolicy
10
-{
11
-    use HandlesAuthorization;
12
-
13
-    /**
14
-     * Determine whether the user can view any models.
15
-     *
16
-     * @param  \App\Models\User  $user
17
-     * @return \Illuminate\Auth\Access\Response|bool
18
-     */
19
-    public function viewAny(User $user)
20
-    {
21
-        return $user->role_id === 1;
22
-    }
23
-
24
-    /**
25
-     * Determine whether the user can view the model.
26
-     *
27
-     * @param  \App\Models\User  $user
28
-     * @param  \App\Models\Report  $report
29
-     * @return \Illuminate\Auth\Access\Response|bool
30
-     */
31
-    public function view(User $user, Report $report)
32
-    {
33
-        return $user->role_id === 1;
34
-    }
35
-
36
-    /**
37
-     * Determine whether the user can create models.
38
-     *
39
-     * @param  \App\Models\User  $user
40
-     * @return \Illuminate\Auth\Access\Response|bool
41
-     */
42
-    public function create(User $user)
43
-    {
44
-        return $user->role_id === 1;
45
-    }
46
-
47
-    /**
48
-     * Determine whether the user can update the model.
49
-     *
50
-     * @param  \App\Models\User  $user
51
-     * @param  \App\Models\Report  $report
52
-     * @return \Illuminate\Auth\Access\Response|bool
53
-     */
54
-    public function update(User $user, Report $report)
55
-    {
56
-        return $user->role_id === 1;
57
-    }
58
-
59
-    /**
60
-     * Determine whether the user can delete the model.
61
-     *
62
-     * @param  \App\Models\User  $user
63
-     * @param  \App\Models\Report  $report
64
-     * @return \Illuminate\Auth\Access\Response|bool
65
-     */
66
-    public function delete(User $user, Report $report)
67
-    {
68
-        return $user->role_id === 1;
69
-    }
70
-
71
-    /**
72
-     * Determine whether the user can restore the model.
73
-     *
74
-     * @param  \App\Models\User  $user
75
-     * @param  \App\Models\Report  $report
76
-     * @return \Illuminate\Auth\Access\Response|bool
77
-     */
78
-    public function restore(User $user, Report $report)
79
-    {
80
-        //
81
-    }
82
-
83
-    /**
84
-     * Determine whether the user can permanently delete the model.
85
-     *
86
-     * @param  \App\Models\User  $user
87
-     * @param  \App\Models\Report  $report
88
-     * @return \Illuminate\Auth\Access\Response|bool
89
-     */
90
-    public function forceDelete(User $user, Report $report)
91
-    {
92
-        //
93
-    }
94
-}

+ 18
- 1
app/Providers/AuthServiceProvider.php Целия файл

@@ -2,7 +2,18 @@
2 2
 
3 3
 namespace App\Providers;
4 4
 
5
+use App\Models\Customer;
6
+use App\Models\Product;
7
+use App\Models\Purchase;
8
+use App\Models\StockProduct;
9
+use App\Models\Supplier;
5 10
 use App\Models\User;
11
+use App\Policies\CustomerPolicy;
12
+use App\Policies\ProductPolicy;
13
+use App\Policies\PurchasePolicy;
14
+use App\Policies\SalePolicy;
15
+use App\Policies\StockProductPolicy;
16
+use App\Policies\SupplierPolicy;
6 17
 use App\Policies\UserPolicy;
7 18
 use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
8 19
 
@@ -15,7 +26,13 @@ class AuthServiceProvider extends ServiceProvider
15 26
      */
16 27
     protected $policies = [
17 28
         // Class::class => ClassPolicy::class,
18
-        User::class => UserPolicy::class
29
+        Customer::class => CustomerPolicy::class,
30
+        Product::class => ProductPolicy::class,
31
+        Purchase::class => PurchasePolicy::class,
32
+        Sale::class => SalePolicy::class,
33
+        StockProduct::class => StockProductPolicy::class,
34
+        Supplier::class => SupplierPolicy::class,
35
+        User::class => UserPolicy::class,
19 36
     ];
20 37
 
21 38
     /**