Spamworldpro Mini Shell
Spamworldpro


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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/corals-api/Corals/modules/Timesheet/update-batches/1.0.9.php
<?php


use Corals\Modules\Timesheet\Models\Entry;
use Corals\Modules\Timesheet\Models\Project;
use Corals\User\Models\User;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::create('timesheet_assignment_project', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('project_id');
    $table->unsignedInteger('user_id');

    $table->foreign('user_id')
        ->references('id')
        ->on('users')
        ->cascadeOnDelete()
        ->cascadeOnUpdate();

    $table->foreign('project_id')
        ->references('id')
        ->on('timesheet_projects')
        ->cascadeOnDelete()
        ->cascadeOnUpdate();

    $table->text('properties')->nullable();

    $table->timestamps();
});

Schema::table('timesheet_projects', function (Blueprint $table) {
    $table->boolean('assignable')
        ->after('bill_cycle_starts_at')
        ->default(false);
});

Project::query()->where('timesheet_projects.id', '<>', 1)
    ->update([
        'assignable' => 1
    ]);

User::query()->each(function (User $user) {
    $userProjects = Entry::query()
        ->where('user_id', $user->id)
        ->where('timesheet_entries.project_id', '<>', 1)
        ->pluck('project_id')
        ->unique()
        ->values()
        ->toArray();

    $user->projects()->sync($userProjects);
});

Spamworldpro Mini