66use App \Models \Enums \BudgetType ;
77use App \Models \FiscalYear ;
88use Illuminate \Http \RedirectResponse ;
9+ use Illuminate \Support \Facades \Gate ;
910
1011class BudgetPlanController extends Controller
1112{
1213 public function index ()
1314 {
14- $ this -> authorize ('viewAny ' , BudgetPlan::class);
15+ Gate:: authorize ('viewAny ' , BudgetPlan::class);
1516
1617 $ years = FiscalYear::orderByDesc ('start_date ' )->get ();
1718
@@ -23,7 +24,7 @@ public function index()
2324 public function show (int $ plan_id )
2425 {
2526 $ plan = BudgetPlan::findOrFail ($ plan_id );
26- $ this -> authorize ('view ' , $ plan );
27+ Gate:: authorize ('view ' , $ plan );
2728 $ items = [
2829 BudgetType::INCOME ->slug () => $ plan ->budgetItemsTree (BudgetType::INCOME ),
2930 BudgetType::EXPENSE ->slug () => $ plan ->budgetItemsTree (BudgetType::EXPENSE ),
@@ -34,7 +35,7 @@ public function show(int $plan_id)
3435
3536 public function create (): RedirectResponse
3637 {
37- $ this -> authorize ('create ' , BudgetPlan::class);
38+ Gate:: authorize ('create ' , BudgetPlan::class);
3839 $ plan = BudgetPlan::create (['state ' => 'draft ' ]);
3940 $ groups = $ plan ->budgetItems ()->createMany ([
4041 ['is_group ' => 1 , 'budget_type ' => BudgetType::INCOME , 'position ' => 0 , 'short_name ' => 'E1 ' ],
@@ -51,8 +52,6 @@ public function create(): RedirectResponse
5152 ]);
5253 });
5354
54- return redirect ()-> route ('budget-plan.edit ' , ['plan_id ' => $ plan ->id ]);
55+ return to_route ('budget-plan.edit ' , ['plan_id ' => $ plan ->id ]);
5556 }
5657}
57-
58-
0 commit comments