%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/hr/api/app/Http/Controllers/Api/v1/
Upload File :
Create Path :
Current File : /var/www/html/hr/api/app/Http/Controllers/Api/v1/ConfigurationsController.php

<?php

namespace App\Http\Controllers\Api\v1;


use App\Http\Controllers\Api\ApiController;
use App\Http\Requests\Api\v1\Configurations\CreateConfigurationRequest;
use App\Models\Configuration;
use App\Transformers\ConfigurationTransformer;
use App\Transformers\DayTransformer;
use Throwable;

class ConfigurationsController extends ApiController
{
    /**
     * @var DayTransformer
     */
    private $transformer;

    public function __construct(ConfigurationTransformer $transformer)
    {
        $this->transformer = $transformer;
    }

    public function index()
    {
        return $this->item(Configuration::getCurrent(), $this->transformer);
    }

    public function update(CreateConfigurationRequest $request, $configuration)
    {
        try {
            /** @var Configuration $configuration */
            $configuration = Configuration::query()
                                          ->findOrFail($configuration);
            $configuration->updateItem($request->only([
                'should_get_holidays_from_working_day_overtime',
                'holidays_percentage_from_working_day_overtime',
                'should_get_holidays_from_non_working_day_overtime',
                'holidays_percentage_from_non_working_day_overtime',
                'should_postpone_holidays',
                'holidays_validity_in_months',
                'expected_daily_working_hours',
                'overtime_percentage_on_working_day',
                'overtime_percentage_on_non_working_day',
                'out_sick_percentage',
                'valid_from',
                'valid_to',
                'annual_leave_quantity',
            ]));
            return $this->item($configuration, $this->transformer);
        } catch (Throwable $e) {
            return $this->wrongArguments([
                'message' => $e->getMessage(),
            ]);
        }
    }

    public function destroy($day)
    {
        Configuration::destroy($day);
        return $this->noContent();
    }

}

Zerion Mini Shell 1.0