<commit_before><?php

namespace App\Http\Controllers\Manager;

use Flash;
use Carbon\Carbon;
use App\Models\Vacancy;
use App\Models\Business;
use Illuminate\Http\Request;
use App\Services\VacancyService;
use App\Http\Controllers\Controller;

class BusinessVacancyController extends Controller
{
    /**
    * Show the form for creating a new resource.
    *
    * @return Response
    */
    public function create(Business $business)
    {
        $this->log->info(__METHOD__);
        $this->log->info(sprintf("  businessId:%s", $business->id));

        //////////////////
        // FOR REFACTOR //
        //////////////////

        $dates = VacancyService::generateAvailability($business->vacancies);
        $services = $business->services;
        if ($services->isEmpty()) {
            return view('manager.businesses.vacancies.edit', compact('business', 'dates', 'services'))
            ->withErrors(array("msg" => trans('manager.vacancies.msg.edit.no_services') ));
        }

        return view('manager.businesses.vacancies.edit', compact('business', 'dates', 'services'));
    }

    /**<commit_msg>Simplify code<commit_after><?php

namespace App\Http\Controllers\Manager;

use Flash;
use Carbon\Carbon;
use App\Models\Vacancy;
use App\Models\Business;
use Illuminate\Http\Request;
use App\Services\VacancyService;
use App\Http\Controllers\Controller;

class BusinessVacancyController extends Controller
{
    /**
    * Show the form for creating a new resource.
    *
    * @return Response
    */
    public function create(Business $business)
    {
        $this->log->info(__METHOD__);
        $this->log->info(sprintf("  businessId:%s", $business->id));

        //////////////////
        // FOR REFACTOR //
        //////////////////

        $dates = VacancyService::generateAvailability($business->vacancies);
        $services = $business->services;

        if ($services->isEmpty()) {
            Flash::warning(trans('manager.vacancies.msg.edit.no_services'));
        }

        return view('manager.businesses.vacancies.edit', compact('business', 'dates', 'services'));
    }

    /**
{'fraction_non_alphanumeric': 0.17194142654700048, 'fraction_numerical': 0.0, 'mean_word_length': 2.6205128205128205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '254117', 'n_tokens_mistral': 604, 'n_tokens_neox': 589, 'n_words': 113}