I have problem with id increasing in laravel

59 views Asked by At

I have the methods finishSave and numbers, when I call numbers from finishSave, and put dd() I took increasing id, so what about problem?

I tried dd($this->prefix_id); in PhoneNumber class Method numbers

protected function finishSave(array $options)
{
    $this->numbers();
    Cache::tags([config('app.env') . '_responsecache'])->flush();
    parent::finishSave($options);
}

and numbers method

public function numbers()
    {
        dd($this->prefix_id);
    }

I expect each time from DB the ID of prefix, but I took increasing id, and how I can get this I cannot understand, so help me

1

There are 1 answers

0
Iskandar Xolboyev On BEST ANSWER

thank you all, occasionly it was my fault, I changed blade file from null to model than it was working, sorry. I have done like this:

<div class="form-group">
        {!! Form::label('region_id', 'Регион:', ['class' => 'text-semibold']) !!}
        {!! Form::select('region_id', $regions, null, ['class'=>'form-control']) !!}
    </div>

and changed to that:

<div class="form-group">
        {!! Form::label('region_id', 'Регион:', ['class' => 'text-semibold']) !!}
        {!! Form::select('region_id', $regions, isset($phoneNumber) ? $phoneNumber->phonePrefix->region_id : null, ['class'=>'form-control']) !!}
    </div>