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 @@
{
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) {
DB::table('permissions')->insertOrIgnore([
'name' => $perm,
'guard_name' => 'web',
'name' => $perm['name'],
'module' => $perm['module'],
'action' => $perm['action'],
'created_at' => now(),
'updated_at' => now(),
]);
}
// Also seed the 5050 account if missing
$academies = DB::table('academies')->pluck('id');
foreach ($academies as $academyId) {
DB::table('financial_accounts')->insertOrIgnore([
'academy_id' => $academyId,
'code' => '5050',
'name' => 'Miscellaneous Expenses',
'name_ar' => 'مصروفات نثرية',
'type' => 'expense',
'category' => 'operating',
'is_system' => true,
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]);
$exists = DB::table('financial_accounts')
->where('academy_id', $academyId)
->where('code', '5050')
->exists();
if (!$exists) {
DB::table('financial_accounts')->insert([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'academy_id' => $academyId,
'code' => '5050',
'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