sumitgroup
2 months ago
429
2
Laravel

How to get Current project Value on Click in Laravel Form?

Posted 2 months ago by sumitgroup

I have multiple projects list on a single page, and each project have a send query button. When i am clicking on send query button then i am getting name, email, phone on mail, but i want something like this, when someone click on send query button then current click project name should be append in form and i will get the information by mail.

Here are my HTML Button Code...

<a href="javascript:void()">
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal">Send Query</button>
     </a>

and here are my form data..

	<div class="modal fade" id="myModal" role="dialog" style="margin-top: 100px;">
<div class="modal-dialog">
	<!-- Modal content-->
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4 class="modal-title">Send Query For Rent</h4>
		</div>
		<div class="modal-body">
			<form class="form-horizontal" action="{{url('/send_Your_mail')}}" method="post">
				@csrf
				<div class="form-group">
					<div class="col-sm-12">
						<input type="text" class="form-control" id="user_name" placeholder="Enter Your Name" name="user_name" required>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12">
						<input type="email" class="form-control" id="user_email" placeholder="Enter Yorm E-mail" name="user_email" required>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-12">          
						<input type="number" class="form-control" id="user_phone" placeholder="Enter Your Phone" name="user_phone" required>
					</div>
				</div>
				<input type="hidden" name="prop_name" value="prop_name">
				<div class="form-group">        
					<div class="col-sm-offset-2 col-sm-12">
						<button type="submit" class="btn btn-primary">Submit</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>

and here are my controller code...

public function send_Your_mail(Request $r)
  {
$validator = Validator::make($r->all(), [
    'user_name' => 'required',
    'user_email' =>'required',
    'user_phone' =>'required',
]);
if ($validator->fails()) {
    return redirect()->back()->withErrors($validator);
}
$data=[
    'user_email'=>$r->user_email,
    'user_name'=>$r->user_name,
    'user_phone'=>$r->user_phone,
    'user_desc'=>$r->user_desc,
];
Mail::send('mail', $data, function($message) use($data)
{
    $message->from($data['user_email'], 'Email Form sumit');
    $message->to('[email protected]');
    $message->subject($data['user_desc']);
});
return redirect()->back()->with('message','Thanks for Choosing us.');
 }

Please sign in or create an account to participate in this conversation.