gpt4 book ai didi

php - 在资源路由中创建 laravel

转载 作者:行者123 更新时间:2023-12-02 02:41:02 29 4
gpt4 key购买 nike

我为创建 Mission 开发函数和 Blade ,但是当我点击“Ajouter Mission”时,没有任何反应......

请问哪里有问题?

Controller :

 public function create($request, $id)
{
$miss = \App\User::find($id);
$mission = new Mission;
$mission->NOM =$request->input('NOM');
$mission->ID_PERSONNELS = $miss->ID_PERSONNELS;
$mission->ID_NOTE_DE_FRAIS = 1;
$mission->DATE_MISSION = $request->input('DATE_MISSION');
$mission->save();
}

还有我的 Blade 文件:

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Dashboard</div>

<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
@csrf
You are in home as Admin !

</br>
Liste des Utilisateurs
<table class="table table-sstriped card-body">
<thead>
<tr>
<th>Numero Matricule</th>
<th>Nom</th>
<th>Prenom</th>
<th>Rue</th>
<th>Code Postal</th>
<th>Ville</th>
<th>Adresse mail</th>

</tr>
</thead>
<tbody>
@foreach($users as $resp)

<tr>
<td>{{$resp->MATRICULE}}</td>
<td>{{$resp->NOM}}</td>
<td>{{$resp->PRENOM}}</td>
<td>{{$resp->RUE}}</td>
<td>{{$resp->CP}}</td>
<td>{{$resp->VILLE}}</td>
<td>{{$resp->email}}</td>
<td>
<form action="{{action('UserController@destroy', $resp['ID_PERSONNELS'])}}" method="post">
@csrf
<input name="_method" type="hidden" value="DELETE">
<button class="btn btn-danger" type="submit">Supprimer</button>
</form>
</td>

<td>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Ajouter Mission
</button>

<!-- 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">Ajouter une Mission</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body justify-content-center">
<!----------------------------------Body---------------------------------------------->
<label for="NOM" class="col-md-4 col-form-label text-md-center">{{ __('NOM') }}</label>
<div class="col-md-6">
<input id="NOM" type="text" class="form-control @error('NOM') is-invalid @enderror" name="NOM" required autocomplete="NOM" autofocus> @error('NOM')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span> @enderror

</div>


<label for="DATE_MISSION" class="col-md-4 col-form-label text-md-center">{{ __('DATE_MISSION') }}</label>
<div class="col-md-6">
<input id="DATE_MISSION" type="date" class="form-control @error('DATE_MISSION') is-invalid @enderror" name="DATE_MISSION" required autocomplete="DATE_MISSION" autofocus> @error('DATE_MISSION')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span> @enderror

</div>

<!-- <label class="col-md-4 col-form-label text-md-center" for="ID_PRATICIEN">{{ __('PRATICIEN') }}</label> -->

<!-- <select class="custom-select col-md-4 col-form-label text-md-center" id="inputGroupSelect01">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select> -->
<!--------------------------------End----Body------------------------------------>


<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
<button type="submit" href="{{route('mission.create')}}" class="btn btn-primary">Ajouter Mission</button>

</div>
</div>
</div>
</td>



</tr>
</tbody> @endforeach
</div>
</table>
</div>

</div>

</div>
</div>
</div>
@endsection @csrf

谢谢!

最佳答案

这就是您需要在此处更新代码的方式。您需要创建表单并使用提交按钮。

<form action="{{route('mission.create')}}" method="post">

@csrf
<!----------------------------------Body---------------------------------------------->
<label for="NOM" class="col-md-4 col-form-label text-md-center">{{ __('NOM') }}</label>
<div class="col-md-6">
<input id="NOM" type="text" class="form-control @error('NOM') is-invalid @enderror" name="NOM" required
autocomplete="NOM" autofocus>
@error('NOM')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>

<label for="DATE_MISSION" class="col-md-4 col-form-label text-md-center">{{ __('DATE_MISSION') }}</label>
<div class="col-md-6">
<input id="DATE_MISSION" type="date" class="form-control @error('DATE_MISSION') is-invalid @enderror"
name="DATE_MISSION" required autocomplete="DATE_MISSION" autofocus>
@error('DATE_MISSION')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>

<!-- <label class="col-md-4 col-form-label text-md-center" for="ID_PRATICIEN">{{ __('PRATICIEN') }}</label> -->

<!-- <select class="custom-select col-md-4 col-form-label text-md-center" id="inputGroupSelect01">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select> -->
<!--------------------------------End----Body------------------------------------>

<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
<button type="submit" class="btn btn-primary">Ajouter Mission</button>
</form>

关于php - 在资源路由中创建 laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59469121/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com