How to update ids in pivot table in laravel9 - laravel

in laravel 9 i have tables
team (columns are team_name, igl_name, match_id)
tournament
match_id
and tour_team is table (colums are team_id, tournamnet_id and match_id)
in the option I am retrieving match id in value now I want to update this match id with match_id in tour_team, table which is pivot table for that for specific team. and tournament
here is form
<form action="" method="POST">
<div class="form-group">
<div class="form-control-wrap">
<select name="match_id" class="js-select" id="tax-class" data-sort="false">
<option value="">Select an option</option>
#foreach ($matches as $mate)
<option value="{{$mate->id}}">{{$mate->name}}</option>
#endforeach
</select>
</div>
</div>
<button type="submit">Update Match</button>
</form>
Here is complete code of team
#foreach ($team as $item)
#if ($item->pivot->match_id == 0)
<tr style="background-color: #dddddd;">
<td class="tb-col">
<div class="media-group">
<div class="media media-md flex-shrink-0 media-middle media-circle">
<img src="images/product/a.jpg" alt="">
</div>
<div class="media-text">
{{ $item->team_name }}
</div>
</div>
</td>
<td class="tb-col">
<div class="media-group">
<div class="media media-md flex-shrink-0 media-middle media-circle">
<img src="images/product/a.jpg" alt="">
</div>
<div class="media-text">
{{ $item->igl_name }}
<span class="text smaller">{{ $item->igl_id }}</span>
</div>
</div>
</td>
<td class="tb-col tb">
<form action="" method="POST">
<div class="form-group">
<div class="form-control-wrap">
<select name="match_id" class="js-select" id="tax-class" data-sort="false">
<option value="">Select an option</option>
#foreach ($matches as $mate)
<option value="{{$mate->id}}">{{$mate->name}}</option>
#endforeach
</select>
</div>
</div>
<button type="submit">Update Match</button>
</form>
</td>
<td>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#example-{{ $item->id }}">
<em class="icon fa fa-users"></em>
</button>
<!-- Modal -->
<div class="modal fade" id="example-{{ $item->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalScrollableTitle">{{ $item->team_name }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
#foreach ($item->members as $members)
<div class="media-group">
<div class="media media-md flex-shrink-0 media-middle media-circle">
<img src="images/product/a.jpg" alt="">
</div>
<div class="media-text">
{{ $members->player_name }}
<span class="text smaller">{{ $members->player_id }}</span>
</div>
</div>
#endforeach
</div>
</td>
<td>
<button type="button" class="btn btn-color-primary btn-hover-primary btn-icon"><i class="fa-solid fa-ban"></i></button>
</td>
</tr>
#endif
#endforeach
want to update id in pivot table in laravel9

Related

Edit bootstrap Modal Laravel 8

I'm using Laravel 8 and bootstrap modal to edit a modal,
I'm trying to update "courrier", when I press the buttom "Modifier", the modal shows, but The data doesn't get updated, I didn't get it!
Here is my listeCourriersBog.blade.php page:
#section('scripts')
<script type="text/javascript">
#if ((count($errors) > 0) and (session("NON")) )
$('#ModalCreate').modal('show');
#endif
</script>
<script type="text/javascript">
#if ((count($errors) > 0) and (session("NO")) )
$("#ModalEdit{{$courrier->id}}").modal('show');
#endif
</script>
#endsection
#section('contenu')
<div class="x_panel">
<div class="x_title">
<h2>Liste des courriers</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<div class="card-box table-responsive">
<p class="text-muted font-13 m-b-30">
<a href="#" class="buttonPrevious buttonDisabled btn btn-primary" data-
toggle="modal" data-target="#ModalCreate"> <i class="fa fa-plus"></i>
Ajouter un nouveau courrier</a>
<br>
<!-- <a href="{{ route('ajoutCourrier') }}" class="buttonPrevious
buttonDisabled btn btn-primary">Ajouter un nouveau courrier</a>
<br>
-->
<b style=""> Nombre total de courriers
<span class="badge badge-danger"> {{count($courriers)}}</span>
<br>
#if(session("courrier_created"))
<div class="alert alert-success alert-dismissible "
role="alert">
<button type="button" class="close" data-dismiss="alert"
aria-label="Close"><span aria-hidden="true">×</span>
</button>
<strong></strong> Le courrier a été ajouté avec succès.
</div>
#endif
#if(session("courrier_updated"))
<div class="alert alert-success alert-dismissible "
role="alert">
<button type="button" class="close" data-dismiss="alert"
aria-label="Close"><span aria-hidden="true">×</span>
</button>
<strong></strong> Le courrier a été mis à jour avec succès.
</div>
#endif
</p>
<table id="datatable-responsive" class="table table-striped table-bordered dt-
responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>Bog</th>
<th>Référence du courrier</th>
<th>Type du courrier</th>
<th>Expediteur</th>
<th>Date du courrier</th>
<th>Date d'arrivée</th>
<th>Actions</th>
<th>Objet</th>
</tr>
</thead>
<tbody>
#foreach($courriers as $key => $courrier)
<tr>
#if($courrier['Type']['type_lib'] == 'Ordinaire')
<td>{{ $courrier->bog_ord }}</td>
#endif
#if($courrier['Type']['type_lib'] == 'Interne')
<td>{{ $courrier->bog_int }}</td>
#endif
#if($courrier['Type']['type_lib'] == 'Wilaya')
<td>{{ $courrier->bog_wil }}</td>
#endif
#if($courrier['Type']['type_lib'] == 'Ministere')
<td>{{ $courrier->bog_min }}</td>
#endif
#if($courrier['Type']['type_lib'] == 'Daira/Apc')
<td>{{ $courrier->bog_da }}</td>
#endif
#if($courrier['Type']['type_lib'] == 'Avenant')
<td>{{ $courrier->bog_av }}</td>
#endif
<td>{{ $courrier->courrier_num }}</td>
<td> {{ $courrier['Type']['type_lib'] }}</td>
<td>{{ $courrier->expediteur }}</td>
<td>{{ $courrier->date_courrier }}</td>
<td> {{ $courrier->created_at }}</td>
<td>
#if($courrier->sdg_num == '')
<a class="" href="{{ route('modifierCourrierPost', $courrier->id) }}"
data-toggle="modal" data-target="#ModalEdit{{$courrier->id}}">
<span class="badge badge-primary"><i class="fa fa-edit"></i>
Modifier</span>
</a>
#else
<span class="badge badge-success">Transmis</span>
#endif
</td>
<td> {{ $courrier->objet }}</td>
#include('MODAL.edit')
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
And my edit.blade.php modal:
<form action="{{ route('modifierCourrierPost', $courrier->id) }}" method="post"
enctype="multipart/form-data">
#csrf
<div class="modal fade bs-example-modal-lg" id="ModalEdit{{$courrier->id}}"
tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Mettre à jour le courrier</h4>
<button type="button" class="close" data-dismiss="modal"><span aria-
hidden="true">×</span>
</button>
</div>
<div class="modal-body">
#if(session("NO"))
<div class="alert alert-danger alert-dismissible " role="alert">
<button type="button" class="close" data-dismiss="alert" aria-
label="Close"><span aria-hidden="true">×</span>
</button>
<strong>Courrier non valide!</strong> {{ session("NO")}}
</div>
#endif
<div class="field item form-group">
<label class="col-form-label col-md-3 col-sm-3 label-
align">Référence du courrier<span class="required"></span></label>
<div class="col-md-6 col-sm-6">
<input type="text" class="form-control #if($errors-
>has('courrier_num')) is-invalid #endif" value="{{
$courrier['courrier_num'] }}" name="courrier_num" data-validate-
length-range="5,15" >
#if($errors->has("courrier_num"))
<div class="invalid-feedback" role="alert">
<strong>{{ $errors->first("courrier_num") }}
</strong>
</div>
#endif
</div>
</div>
<div class="field item form-group">
<label class="col-form-label col-md-3 col-sm-3 label-align">Type
du courrier<span class="required">*</span></label>
<div class="col-md-6 col-sm-6">
<select class="form-control" value="{{ $courrier['type_id']
}}" name="type_id">
<option></option>
#foreach($type_lib as $type)
<option value="{{$type->id}}" {{($type->id == $courrier-
>type_id ) ? 'selected' : '' }}> {{$type->type_lib}}
</option>
#endforeach
</select>
</div>
</div>
<div class="field item form-group">
<label class="col-form-label col-md-3 col-sm-3 label-
align">Objet<span class="required">*</span></label>
<div class="col-md-6 col-sm-6">
<textarea class="form-control #if($errors->has('objet')) is-
invalid #endif" name="objet">{{ $courrier['objet'] }}
</textarea>
#if($errors->has("objet"))
<div class="invalid-feedback" role="alert">
<strong>{{ $errors->first("objet") }}</strong>
</div>
#endif
</div>
</div>
<div class="field item form-group">
<label class="col-form-label col-md-3 col-sm-3 label-
align">Expéditeur<span class="required">*</span></label>
<div class="col-md-6 col-sm-6">
<input class="form-control #if($errors->has('expediteur')) is-
invalid #endif" value="{{ $courrier['expediteur'] }}" type="text"
name="expediteur" data-validate-linked="email" >
#if($errors->has("expediteur"))
<div class="invalid-feedback" role="alert">
<strong>{{ $errors->first("expediteur") }}
</strong>
</div>
#endif
</div>
</div>
<div class="field item form-group">
<label class="col-form-label col-md-3 col-sm-3 label-align">Date
du courrier<span class="required">*</span></label>
<div class="col-md-6 col-sm-6">
<input class="form-control #if($errors->has('date_courrier'))
is-invalid #endif " value="{{ $courrier['date_courrier'] }}"
type="text" data-date-format="d-m-Y" name="date_courrier"
required="required">
#if($errors->has("date_courrier"))
<div class="invalid-feedback" role="alert">
<strong>{{ $errors->first("date_courrier") }}
</strong>
</div>
#endif
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-
dismiss="modal">Fermer</button>
<button type="submit" class="btn btn-primary">Modifier</button>
</div>
</div>
</div>
</div>
</form>
I tried to put the edit modal in the listeCourriersBog.blade.php but when I click, only the last courrier get updated!
Don't know how to fix that

can't refresh a page after updateing a form in laravel

hello i need to do an update inside a model using Laravel, the problem is when i click on the update button (his name in the code is Modifier) the page is not refreshing.
i have tried to work with an a tag in place of button .and with the a tag the page refresh but my data is not updating.
can someone tell me where is the problem in the code
the index view code :
<table class="table table-bordered table-left">
<thead>
<tr>
<th>#</th>
<th>Nom</th>
<th>Email</th>
<th>Rôle</th>
<th>Action</th>
</tr>
</thead>
<tbody>
#foreach ($users as $key=>$user)
<tr>
<td>{{ $key+1 }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>
#if ($user->is_admin==1)Administrateur
#else Caissier
#endif
</td>
<td>
<div class="btn-group">
<a class="btn btn-success" href="" data-toggle="modal" data-target="#edituser{{ $user->id }}">
<i class="fas fa-edit"></i>
</a>
<a href="" class="btn btn-danger">
<i class="fas fa-trash"></i>
</a>
</div>
</td>
</tr>
{{-- edit model --}}
<div class="modal right fade" id="edituser{{ $user->id }}" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="staticBackdropLabel">Modifier l'utilisateur</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="{{ route('users.update', $user->id) }}" method="post">
#csrf
#method('put')
<div class="form-group">
<label for="name">Nom</label>
<input type="text" value="{{ $user->name }}" name="name" class="form-control">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" value="{{ $user->email }}" name="email" class="form-control">
</div>
<div class="form-group">
<label for="name">Mot de passe</label>
<input type="password" readonly name="password" value="{{ $user->password }}" class="form-control">
</div>
{{-- <div class="form-group">
<label for="name">Confirmer le mot de passe</label>
<input type="password" name="confirm_password" class="form-control">
</div> --}}
<div class="form-group">
<label for="name">Rôle</label>
<select name="is_admin" id="" class="form-control">
<option value="1" #if ($user->is_admin==1)
selected
#endif>Administrateur</option>
<option value="2" #if ($user->is_admin==2)
selected
#endif>Caissier</option>
</select>
</div>
<div >
<button class="btn btn-success btn-block">Modifier</button>
</div>
</form>
</div>
</div>
</div>
</div>
#endforeach
</tbody>
</table>
the controller code :
public function update(Request $request, $id)
{
$users = User::find($id);
if (!$users) {
return back()->with('Error','user created');
}
$users->update($request->all());
return back()->with('Success','user created');
}
Your button
<button class="btn btn-success btn-block">Modifier</button>,
should be
<button class="btn btn-success btn-block" type="submit">Modifier</button> in order to submit the form to your controller.

Laravel 5.5 - MethodNotAllowedHttpException

I have an task using Laravel. Which one on my task, user can edit the data on master data table. I'm using modal pop when user want to edit the data. So the user no need to move the page for edit data. On my task I'm using Laravel 5.5
Here is my code :
This is for tabel modal edit
<div class="modal fade" id="edit-modal" tabindex="-1" role="dialog" aria-labelledby="largeModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header no-bd">
<h5 class="modal-title">
<span class="fw-mediumbold">Detail</span>
<span class="fw-light">Data</span>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="form-material form-horizontal" method=post action="{{route('masterdataobjek.update', 'test')}}">
{{ csrf_field() }}
<div class="row">
<div class="col-sm-12">
<input type="hidden" name="id_objek" id="id_objek_modal" value="">
<div class="form-group form-group-default">
<label>Nama Objek</label>
<input id="objek_nama_modal" type="text" name="objek_nama_modal" class="form-control">
</div>
</div>
<div class="col-sm-12">
<div class="form-group form-group-default">
<label for="comment">Deskripsi Objek</label>
<textarea class="form-control" name="objek_desc_modal" id="objek_desc_modal" rows="5"></textarea>
</div>
</div>
<div class="col-sm-12">
<label for="exampleFormControlFile1">Upload WTO File</label>
<div class="form-group form-group-default">
<input type="file" class="form-control-file" name="objek_wto" id="objek_wto">
</div>
</div>
</div>
<div class="modal-footer no-bd">
<button type="submit" class="btn btn-primary">Update</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
</div>
For the button clicked code ;
<tbody>
#foreach ($tabelobjek as $ta => $data)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $data->objek_nama}}</td>
<td style="">{{str_limit($data->objek_desc,15)}}</td>
<td>
<div class="form-button-action">
<button type="button" data-toggle="modal"
class="btn btn-link btn-success btn-lg" data-original-title="Edit"
data-target="#edit-modal" id="edit-button"
data-idobjek="{{$data->id_objek}}"
data-namaobjek="{{$data->objek_nama}}"
data-objekdeskripsi="{{$data->objek_desc}}">
<i class="fa fa-edit"></i>
</button>
</div>
</td>
</tr>
#endforeach
</tbody>
for trigger button :
<script>
$(document).ready(function () {
$(document).on('click', '#edit-button', function () {
var namaobjek = $(this).data('namaobjek');
var objekdeskripsi = $(this).data('objekdeskripsi');
var idobjek = $(this).data(idobjek)
$('#id_objek_modal').val(idobjek)
$('#objek_nama_modal').val(namaobjek);
$('#objek_desc_modal').val(objekdeskripsi);
})
})
MasterDataObjekController.php
public function update(Request $request)
{
$updateObjek = TbObjek::findOrFail($request->id_objek);
$updateObjek->update($request->all());
return back();
}
POST requests are for creating new records, PUT and PATCH are for updating records. Refer to the table of HTTP methods on Laravel RESTful containers here
You need to change your form tag from this
<form class="form-material form-horizontal" method=post action="{{route('masterdataobjek.update', 'test')}}">
to this
<form class="form-material form-horizontal" method="put" action="{{route('masterdataobjek.update', 'test')}}">

Laravel Bootstrap Modal Submit button not working

I'm crazy trying to make a modal window return the control to my view. The button type is submit but it doesn't launch the route. I've seen some tutorials and there, all I have to do for create is to define action as the route and have a submit button. I've seen that, no need of ajax, or I'm not aware when they wrote the code... I went to w3c and there at the "try it yourself" I agregated the submit button, and effectively the window is not closed. So I'm totally stuck, some help would be appreciated.
Part of my view
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
<h1 class="h5">Horarios</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group mr-2">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#create-horario">+</button>
<div class="modal fade" id="create-horario" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" >
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalLabel">Nuevo horario</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form action="{{ route('horarioperiodicos.store')}}" method="post">
<!-- {{ method_field('patch')}} -->
{{ csrf_field() }}
<div class="modal-body">
<div class="form-group">
<label for="diaSemana" class="col-form-label">Día de la semana</label>
<select name="diaSemana" class="form-control">
<option value="1" selected> Lunes</option>
<option value="2" > Martes</option>
<option value="3" > Miércoles</option>
<option value="4" > Jueves</option>
<option value="5" > Viernes</option>
<option value="6" > Sábado</option>
<option value="7" > Domingo</option>
</select>
</div>
<div class="form-group">
<div style="width:50%;float:left;display:inline-block;">
<label for="HoraInicio" class="col-form-label">Hora de inicio</label>
<input type="time" id="HoraInicio" name="HoraInicio" min="9:00" max="18:00" value="09:00" >
</div>
<div align="right">
<label for="HoraFin" class="col-form-label">Hora de fin</label>
<input type="time" id="HoraFin" name="HoraFin" min="9:00" max="18:00" value="10:00">
</div>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<button type="submit" class="btn btn-primary" id="submitForm">Guardar</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<table class="table">
<thead class="thead-light">
<tr>
<th>Día</th>
<th>Hora de inicio</th>
<th>Hora de fin</th>
<th>Cambios</th>
</tr>
</thead>
<tbody>
#foreach($horarioPeriodicos as $horario)
<tr>
<td>
#switch( $horario->intDia )
#case( 1 )
Lunes
#break
#case( 2 )
Martes
#case( 3 )
Miércoles
#break
#case( 4 )
Jueves
#case( 5 )
Viernes
#case( 6 )
Sábado
#default
Domingo
#break
#endswitch
</td>
<td> {{ $horario->timHoraInicio }} </td>
<td> {{ $horario->timHoraFin }} </td>
<td>
<button class="btn btn-sm btn-outline-secondary">-</button> /
<button class="btn btn-sm btn-outline-secondary">Editar</button>
</td>
</tr>
#endforeach
</tbody>
</table>
</main>
HorarioPeriodicosController (don't get to it and is in my rotes list)
public function store(Request $request)
{
//
dd(1);
}
My routes list
I tryed modifying this
<form action="{{ route('horarioperiodicos.store')}}" method="post">
{{ method_field('patch')}}
for this
<form action="{{ route('horarioperiodicos.store')}}" >
etc, etc.
Something rare is that even when I do changes there, It doesn't launch errors.
Thanks a lot
You need to place your <button> inside of the <form> element.
Otherwise the form will not be triggered to submit.
Alternatively you can place the button outside of the form, but you need to include the form= attribute that corresponds with the form's id= attribute in the button element:
<form id="myform" method="post" action="{{ route('store.create') }}">
<input type="text" name="name" />
</form>
<input type="submit" form="myform" />

When I click on edit button give me error

When I click in edit button it gives me a error, what is problem I can not understand now, please help me
Trying to get property 'id' of non-object (View: C:\xampp\htdocs\ytl\resources\views\profile\edit.blade.php)
This is my userprofilecontroller
public function edit( Request $request, $id){
$user_profile_id = UserProfile::where('id', '=', $id)->firstOrFail();
$exchanges = Exchange::pluck('exchange','id')->all();
$markets = Market::pluck('market','id')->all();
$countries = Country::pluck('country','id')->all();
$brokerage_company = BrokerageCompany::pluck ('brokerage_company','id')->all();
$user_profile = UserProfile::pluck('charge_intraday','charge_delivery','charge_per_lot','charge_per_order')->all();
return view('profile.edit', compact('user_profile_id','exchanges','markets','countries','brokerage_company','user_profile'));
}
public function update(Request $request, $id){
$user_profile_id = UserProfile::findOrFail($id);
$input = $request->except( 'brokerage_company','user_profile');
$user_id = $user_profile->update($input);
return redirect('/profile');
}
This is profile\index.blade.php file
<div class="card card-table">
<div class="card-header">Basic Tables
<div class="tools dropdown"><span class="icon mdi mdi-download"></span><a class="dropdown-toggle" href="#" role="button" data-toggle="dropdown"><span class="icon mdi mdi-more-vert"></span></a>
<div class="dropdown-menu" role="menu"><a class="dropdown-item" href="#">Action</a><a class="dropdown-item" href="#">Another action</a><a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider"></div><a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
</div>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th style="width:10%;">Country</th>
<th style="width:10%;">Exchange</th>
<th class="number">Market</th>
<th class="number">Company</th>
<th class="actions">Charges</th>
</tr>
</thead>
#if($user_profile)
<tbody>
#foreach($user_profile as $user_profiles)
<tr>
<td>{{$user_profiles->country->country}}</td>
<td>{{$user_profiles->exchange->exchange}}</td>
<td>{{$user_profiles->market->market}}</td>
<td>{{$user_profiles->brokerage_company->brokerage_company}}</td>
<td class="cell-detail"><span>Intaday-charge</span>{{$user_profiles->charge_intraday}}
<span class="cell-detail-description">Delivery-charge</span>
{{$user_profiles->charge_delivery}}</td>
{{--<td>{{$user_profiles->charge_per_lot}}</td>--}}
{{--<td>{{$user_profiles->charge__per_order}} </td>--}}
<td> <a class="btn btn-info btn-sm" href="{{route('profile.edit', $user_profiles->id)}}">Edit</a></td>
</tr>
#endforeach
</tbody>
#endif
</table>
</div>
</div>
This is profile\edit.blade.php file
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Add Charge</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
{{--<form method="PATCH", id="form", action="{{action('Profile\UserProfileController#update',$user_profile_id->id)}} ", accept-charset="UTF-8">--}}
{{--{{ csrf_field() }}--}}
{{--{{ method_field('PATCH') }}--}}
{!! Form::model($user_profile,['method'=>'PATCH', 'action'=> ['Profile\UserProfileController#update',$user_profile->id]]) !!}
<div class="row">
<div class="col-md-6 mb-3 form-group">
Country:<select name="country_id" id="country" class="form-control " onchange="myfunc()" >
<option value="">Select</option>
#foreach($countries as $key=>$val )
<option value="{{ $val->id }}">{{ $val->country }}</option>
#endforeach
</select>
</div>
<div class="col-md-6 mb-3 form-group">
Exchange:<select name="exchange_id" id="exchange" class="form-control notselect" onchange="myfunc1()">
<option value="">Select</option>
{{--#foreach($exchanges as $key=>$val )--}}
{{--<option value="{{ $val->id }}">{{ $val->exchange }}</option>--}}
{{--#endforeach--}}
</select>
</div>
<div class="col-md-6 mb-3 form-group">
Market<select name="market_id" id="market" class="form-control bindselect" >
<option value="">Select</option>
{{--#foreach($markets as $key=>$val )--}}
{{--<option value="{{ $val->id }}">{{ $val->market }}</option>--}}
{{--#endforeach--}}
</select>
</div>
<div class="col-md-6 mb-3 form-group">
Company:<select name="brokerage_company_id" id="brokerage_company_id" class="form-control " >
<option value="">Select</option>
#foreach($brokerage_company as $key=>$val)
<option value="{{ $val->id }}">{{ $val->brokerage_company }}</option>
#endforeach
</select>
</div>
<div class="col-md-6 mb-3 form-group">
Intraday_charge: <input type="text" name="charge_intraday" class="form-control"><br>
</div>
<div class="col-md-6 mb-3 form-group">
Delivery_charge: <input type="text" name="charge_delivery" class="form-control"><br>
</div>
<div class="col-md-6 mb-3 form-group">
Delivery_charge: <input type="text" name="charge_per_lot" class="form-control"><br>
</div>
<div class="col-md-6 mb-3 form-group">
Delivery_charge: <input type="text" name="charge_per_order" class="form-control"><br>
</div>
{!! Form::close() !!}
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" value="Submit" name="form1" class="btn btn-primary">Save changes</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
It seems like you misunderstood the Pluck method. Pluck is to take several properties out an array by their key. Nothing to do with selecting columns from a Database.
I guess you want to select a single UserProfile. And the right way of doing this is as follows:
public function edit(Request $request, $id){
$user_profile = UserProfile::findOrFail($id); // Select a UserProfile by ID or fail
$exchanges = Exchange::all('exchange', 'id');
$markets = Market::all('market','id');
$countries = Country::all('country','id');
$brokerage_company = BrokerageCompany::all ('brokerage_company','id');
// I dont know what you want with this statement?
// $user_profile = UserProfile::pluck('charge_intraday','charge_delivery','charge_per_lot','charge_per_order')->all();
return view('profile.edit', compact('user_profile','exchanges','markets','countries','brokerage_company'));
}

Resources