Commit e903c1d9 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix permissions migration — match actual table schema (no guard_name)

Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 3c335666
...@@ -7,32 +7,44 @@ ...@@ -7,32 +7,44 @@
{ {
public function up(): void public function up(): void
{ {
$permissions = ['expenses.create', 'expenses.list', 'expenses.view']; $permissions = [
['name' => 'expenses.create', 'module' => 'expenses', 'action' => 'create'],
['name' => 'expenses.list', 'module' => 'expenses', 'action' => 'list'],
['name' => 'expenses.view', 'module' => 'expenses', 'action' => 'view'],
];
foreach ($permissions as $perm) { foreach ($permissions as $perm) {
DB::table('permissions')->insertOrIgnore([ DB::table('permissions')->insertOrIgnore([
'name' => $perm, 'name' => $perm['name'],
'guard_name' => 'web', 'module' => $perm['module'],
'action' => $perm['action'],
'created_at' => now(), 'created_at' => now(),
'updated_at' => now(),
]); ]);
} }
// Also seed the 5050 account if missing // Also seed the 5050 account if missing
$academies = DB::table('academies')->pluck('id'); $academies = DB::table('academies')->pluck('id');
foreach ($academies as $academyId) { foreach ($academies as $academyId) {
DB::table('financial_accounts')->insertOrIgnore([ $exists = DB::table('financial_accounts')
'academy_id' => $academyId, ->where('academy_id', $academyId)
'code' => '5050', ->where('code', '5050')
'name' => 'Miscellaneous Expenses', ->exists();
'name_ar' => 'مصروفات نثرية',
'type' => 'expense', if (!$exists) {
'category' => 'operating', DB::table('financial_accounts')->insert([
'is_system' => true, 'uuid' => (string) \Illuminate\Support\Str::uuid(),
'is_active' => true, 'academy_id' => $academyId,
'created_at' => now(), 'code' => '5050',
'updated_at' => now(), 'name' => 'Miscellaneous Expenses',
]); 'name_ar' => 'مصروفات نثرية',
'type' => 'expense',
'category' => 'operating',
'is_system' => true,
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment