mysql - 使用单个表单将数据保存到两个表
问题描述
我有一个输入餐厅详细信息的表格
@extends('layouts.app')
@section('content')
<html>
<head>
</head>
<body>
<h3 class="text-center"><u>Create Restaurant</u></h3>
<div class="container">
{!! Form::open(['action' => 'RestaurantsController@store','method'=>'POST','enctype'=>'multipart/form-data'])!!}
<div class="form-group">
{{Form::label('name','Name')}}
{{Form::text('name','',['class'=>'form-control','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('opening_time','Opening time')}}
{{Form::time('opening time','',['class'=>'form-control','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('closing_time','Closing time')}}
{{Form::time('closing time','',['class'=>'form-control','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('days_of_operation','Days of operation')}}
{{Form::text('days_of_operation','',['class'=>'form-control','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('website','Website')}}
{{Form::text('website','',['class'=>'form-control','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('email','Email')}}
{{Form::text('email',null,['class'=>'form-control','id'=>'menu','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('phone','Phone')}}
{{Form::text('phone',null,['class'=>'form-control','id'=>'phone','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('pysical_address','Physical address')}}
{{Form::textarea('physical_address','',['class'=>'form-control','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('lat','Latitude')}}
{{Form::number('lat',null,['class'=>'form-control','id'=>'lat','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::label('lon','Longitude')}}
{{Form::number('lon',null,['class'=>'form-control','id'=>'lon','placeholder'=>'Insert here'])}}
</div>
<div class="form-group">
{{Form::file('cover_image')}}
</div>
{{-- {{Form::hidden('_method','POST')}} --}}
{{Form::submit('submit',['class'=>'btn btn-primary','type'=>'submit','id'=>'submit'])}}
{!! Form::close() !!}
</div>
</body>
</html>
@endsection
我需要在坐标表中保存纬度、经度、餐厅 ID
我需要在餐厅表中保存以下详细信息
$restaurant=new Restaurant;
$restaurant->name= $request->input('name');
$restaurant->opening_time=$request->input('opening_time');
$restaurant->physical_address=$request->input('physical_address');
$restaurant->closing_time=$request->input('closing_time');
$restaurant->days_of_operation=$request->input('days_of_operation');
$restaurant->website=$request->input('website');
$restaurant->email=$request->input('email');
$restaurant->phone=$request->input('phone');
$restaurant->cover_image=$fileNameToStore;
$restaurant->save();
我该怎么做?如何查询用户位置附近的餐厅?我知道如何获取当前用户的经度和纬度然后呢?
解决方案
推荐阅读
- python - 3d 数组的不正确重塑
- powershell - 尝试编写接受流水线输入的 powershell cmdlet
- javascript - nodeJS等待移动文件然后压缩图像
- python - 如何使用 BeautifulSoup 检查网站标题的变化?
- laravel - 为什么我的 Google 云端硬盘刷新令牌会在 7 天后过期?
- macos - 在 Apple 的 M1 处理器上提升 C++,安装和构建是否正常?
- c++ - 如何解决错误:无效使用不完整类型“GdkSurface {aka struct _GdkSurface}”?
- xml - xsl:for-each 选择不适用于 XML 中的 xmlns="http://www.example.com/TBD"
- matplotlib - 处理分类数据时绘制多个条形图
- python - 我可以手动排序我的 SQLAlchemyAutoSchema 吗?