Vendor id is not getting stored in database

Select::make('vendor_id') ->required() ->relationship('vendor', 'rzp_cust_id') ->options(function () { return Vendor::join('users', 'vendors.user_id', '=', 'users.id') ->select('vendors.id', 'users.first_name') ->pluck('users.first_name', 'vendors.id'); }) ->searchable() ->preload() ->native(false) ->selectablePlaceholder(false) ->visible(auth()->user()->role_id != 3) ->default(function (){ if(auth()->user()->role_id == 3 ){ // dd(auth()->user()->vendor->id); return auth()->user()->vendor->id;
} }), This is my vendor id field , when role is 3 i want this field to hide and fetch the vendor id and store it in db, but it is not getting stored in db, i also used life cyle hook , but it is also not working protected function beforeCreate(): void{ if(auth()->user()->role_id == 3 ){
$this->data['vendor_id'] = auth()->user()->vendor->id; } } fillable is checked and it is fine
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server