![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/update-batches/ |
<?php use Corals\Modules\Utility\Models\Category\Category; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use Spatie\Permission\PermissionRegistrar; Schema::create('timesheet_expenses', function (Blueprint $table) { $table->id(); $table->unsignedInteger('category_id'); $table->foreign('category_id') ->references('id') ->on('utility_categories') ->restrictOnDelete() ->cascadeOnUpdate(); $table->foreignId('project_id')->nullable() ->references('id') ->on('timesheet_projects') ->restrictOnDelete() ->cascadeOnUpdate(); $table->foreignId('client_id')->nullable() ->references('id') ->on('timesheet_clients') ->restrictOnDelete() ->cascadeOnUpdate(); $table->string('payment_method')->nullable(); $table->string('currency')->nullable(); $table->unsignedInteger('user_id')->nullable(); $table->foreign('user_id') ->references('id') ->on('users') ->cascadeOnDelete() ->cascadeOnUpdate(); $table->foreignId('invoice_id') ->nullable() ->constrained('timesheet_invoices') ->restrictOnDelete() ->cascadeOnUpdate(); $table->text('notes')->nullable(); $table->date('expense_date')->index(); $table->decimal('amount'); $table->boolean('billable')->index(); $table->string('status')->default('pending')->index(); $table->text('properties')->nullable(); $table->auditable(); $table->softDeletes(); $table->timestamps(); }); $parentCategory = 'Expense Categories'; $childCategory = [ 'IT Expenses', 'Salaries', 'Taxes', 'Transfer fees', 'Rental', 'Electricity bill', 'Internet bill', 'Office Expenses', 'General' ]; $parent = Category::query()->create([ 'name' => $parentCategory, 'slug' => Str::slug($parentCategory, '-'), 'status' => 'active', 'module' => 'Timesheet' ]); foreach ($childCategory as $childName) { Category::query()->create([ 'name' => $childName, 'slug' => Str::slug($childName, '-'), 'status' => 'active', 'module' => 'Timesheet', 'parent_id' => $parent->id ]); } $permissionsName = [ 'Timesheet::expense.view', 'Timesheet::expense.create', 'Timesheet::expense.update', 'Timesheet::expense.delete', ]; $permissions = array_map(function ($permission) { return [ 'name' => $permission, 'guard_name' => config('auth.defaults.guard'), 'created_at' => now(), 'updated_at' => now(), ]; }, $permissionsName); DB::table('permissions')->insert($permissions); app(PermissionRegistrar::class)->forgetCachedPermissions();