I am getting a new error and its first time I am facing such error. Whenever I submit form and if it contains '%' in any field, then it shows me the 406 Not Acceptable error.
Also, when I submit the form and any field didn't contain '%' then form is successfully submitted.
I have already tried adding
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
in database.php but it didn't work.
Also, I have found in R&D that by adding 'mysql_real_escape_string' in PHP,, this can be resolved. But ho it can be used in laravel..
Please help me out,
Thanks in advance.
<div id="page-wrapper">
<div id="page-inner">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body">
#include('admin.partials.flash_message')
<form action="{{ $action }}" method="post" enctype="multipart/form-data">
#csrf()
<?php /*#if(!empty($method)) #method($method) #endif*/ ?>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>RFP Title <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" name="rfp_title" value="{{ $pageTitle }}" {{ $prop }} maxlength="100">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>RFP Description <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<textarea id="summernote" name="rfp_description"></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>Organisation <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" name="organisation" value="{{ $pageTitle }}" {{ $prop }} maxlength="100">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>Publish Date <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" name="publish_date" value="{{ $pageTitle }}" {{ $prop }} maxlength="100" readonly>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>Closing Date <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" name="closing_date" value="{{ $pageTitle }}" {{ $prop }} maxlength="100" readonly>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>Company Image <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<input type="file" name="company_image" id="imageUpload" accept=".png,.jpg,.jpeg" class="hide">
<label for="imageUpload" class="upload-poster mr-5">Select file</label> Max Size 2 MB<br>
<img src="{{ asset('public/assets/admin/images/dummy-logo.jpg')}}" id="imagePreview" class="organisation-logo" alt="Your image will appear here.">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>Attachment <span class="text-danger">*</span> :</label>
</div>
<div class="col-md-9">
<input type="file" name="attachment" id="file-2" class="inputfile" data-multiple-caption="{count} files selected" accept=".pdf,.doc,.docx" multiple>
<label for="file-2" class="mr-5"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span>Select File</span></label> Max Size 2 MB
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3">
<label>Contact Person :</label>
</div>
<div class="col-md-9">
<input type="text" class="form-control" name="contact_person" value="{{ $pageTitle }}" {{ $prop }} maxlength="100">
</div>
</div>
</div>
<div class="form-group" style="margin-top: 20px;">
<input type="submit" class="btn btn-primary" value="Submit" name="btn_btn_add_product" {{ $prop }}>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
Related
I am a beginner, and I want to show the value data into the input field related to the key but I am very confused that how can I show the value data into the input field so please if you have an idea please help me thanks.
Database table
Setting table https://ibb.co/jGFX4t2
I want to show a value data in this field, please see https://ibb.co/Mh08c9b
Settings Model
class Settings extends Model
{
protected $table="setting";
protected $fillable =['id','key','value'];
}
Controller
public function setting()
{
$setting=Settings::all();
return view('admin.setting.setting',compact('setting'));
}
HTML view
<form method="post" action="{{route('update.setting')}}" enctype="multipart/form-data" >
#csrf
<div class="card-box">
<div class="panel panel-heading">
<h3>Update Settings</h3>
</div>
<div class="col-lg-5">
<div class="mt-3">
<input type="file" name="logo_image" class="dropify" />
</div>
</div>
<div class="row">
<div class="col-lg-5 mt-3">
<div class="group-form">
<label>Contact Number*</label>
<input type="text" name="contact_number" value="{{ }}" class="form-control" >
</div>
</div>
<div class="col-lg-5 mt-3">
<div class="group-form">
<label>Contact Email *</label>
<input type="email" name="email" value="{{ }}" class="form-control" >
</div>
</div>
<div class="col-lg-10 mt-3">
<div class="group-form">
<label>Location *</label>
<input type="text" name="location" value="{{ }}" class="form-control" >
</div>
</div>
<div class="col-lg-5 mt-3">
<h3> Social Links:</h3>
<div class="group-form">
<label>Facebook *</label>
<input type="text" name="facebook" value="{{ }}" class="form-control" >
</div>
</div>
<div class="col-lg-5 mt-5">
<div class="group-form">
<label>Twitter *</label>
<input type="text" name="twitter" value="{{}}" class="form-control" >
</div>
</div>
<div class="col-lg-6 mt-3">
<div class="group-form">
<label>Linkedin *</label>
<input type="text" name="linkedin" value="{{}}" class="form-control" >
</div>
</div>
<div class="col-lg-7 mt-3">
<div class="group-form ">
<button type="submit" id="btnsubmit" class="btn btn-danger waves-effect waves-light col-lg-2">Save</button>
</div>
</div>
</div>
</div> <!-- end card-box -->
</form>
please use this code.
{{ $setting->Where('key', 'Contact_Email')->first()->value }}
How about something like:
{{ $setting->firstWhere('key', 'Contact_Number')->value; }}
{{ $setting->firstWhere('key', 'Contact_Email')->value; }}
{{ $setting->firstWhere('key', 'Location')->value; }}
etc
When you use Eloquent Model::all(), it returns a collection to the blade view.
Therefore you can use firstWhere to find the key value.
ok this is messed up... there is a simple form with 20 inputs. I'm submitting this form with no values. and my custom validation rules are all "required" . so i want it to show me errors . but the thing is . out of 20 rules any 12 rules work (in random) . as soon as I add 13th rule it stops returning error messages.
//// this is the form ////
<form method="POST" action="{{route('addschoolbranchindb')}}">
#csrf
<div class="col-xl-12 order-xl-1 mt-5">
<div class="card bg-secondary shadow">
<div class="card-header bg-white border-0">
<div class="row align-items-center">
<div class="col-8">
<h3 class="mb-0">Add School Branch</h3>
</div>
<div class="col-4 text-right">
<input type="submit" value="submit" name="submit" class="btn btn-sm btn-primary">
</div>
</div>
</div>
<div class="card-body">
{{ count($errors)}}
<h6 class="heading-small text-muted mb-4">School information</h6>
<div class="row mt-4">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold; width:100%" class="" for="fk_school_id">Select School</label>
</div>
<div class="col-md-8">
<select class="form-control form-control-alternative fk_school_id" id="fk_school_id" name="fk_school_id">
<option value=""></option>
#foreach ($schools as $school)
<option value="{{$school->school_id}}">{{$school->school_name}}</option>
#endforeach
</select>
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('fk_school_id')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="sc_br_name">Branch Name</label>
</div>
<div class="col-md-8">
<input type="text" id="sc_br_name" name="sc_br_name" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Branch Name">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('sc_br_name')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="sc_br_address">School Address</label>
</div>
<div class="col-md-8">
<input type="text" id="sc_br_address" name="sc_br_address" class="disable_on_sc_id form-control form-control-alternative"
placeholder="School Address">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('sc_br_address')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="sc_br_status">School status</label>
</div>
<div class="col-md-8">
<select class="disable_on_sc_id form-control form-control-alternative sc_br_status" id="sc_br_status" name="sc_br_status">
<option value="1">Un-Registered</option>
<option value="2">Under Process</option>
<option value="3">Registered</option>
{{-- #foreach ($schools as $school)
<option value="{{$school->school_id}}">{{$school->school_name}}</option>
#endforeach --}}
</select>
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('sc_br_status')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="no_of_boys">No of Boys</label>
</div>
<div class="col-md-8">
<input type="text" id="no_of_boys" name="no_of_boys" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Number of Boys">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('no_of_boys')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="no_of_girls">No of Girls</label>
</div>
<div class="col-md-8">
<input type="text" id="no_of_girls" name="no_of_girls" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Number of girls">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('no_of_girls')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="sc_br_covered_area">Covered Area</label>
</div>
<div class="col-md-8">
<input type="text" id="sc_br_covered_area" name="sc_br_covered_area" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Total Covered Area">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('sc_br_covered_area')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="no_of_teachers">No of Teachers</label>
</div>
<div class="col-md-8">
<input type="text" id="no_of_teachers" name="no_of_teachers" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Number Of Teachers">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('no_of_teachers')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<hr class="my-4" />
<h6 class="heading-small text-muted mb-4">Owner information</h6>
<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="owner_name">Owner Name</label>
</div>
<div class="col-md-8">
<input type="text" id="owner_name" name="owner_name" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Owner Name">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('owner_name')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="owner_phone">Owner Phone No</label>
</div>
<div class="col-md-7">
<input type="text" id="owner_phone" name="owner_phone" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Owner Number">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('owner_phone')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="owner_email">Owner Email</label>
</div>
<div class="col-md-8">
<input type="text" id="owner_email" name="owner_email" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Owner Email">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('owner_email')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<hr class="my-4" />
<h6 class="heading-small text-muted mb-4">Principal information</h6>
<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="principal_name">Principal Name</label>
</div>
<div class="col-md-8">
<input type="text" id="principal_name" name="principal_name" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Principal Name">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('principal_name')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="principal_phone">Principal Phone No</label>
</div>
<div class="col-md-7">
<input type="text" id="principal_phone" name="principal_phone" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Principal Number">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('principal_phone')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="principal_email">Principal Email</label>
</div>
<div class="col-md-8">
<input type="text" id="principal_email" name="principal_email" class="disable_on_sc_id form-control form-control-alternative"
placeholder="Principal Email">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('principal_email')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<hr class="my-4" />
<h6 class="heading-small text-muted mb-4">Area information</h6>
<div class="row">
<div class="col-md-6">
<div class="col-md-4">
<label style="font-weight:bold" class="" for="pov_for_subarea">Select Province</label>
</div>
<div class="col-md-8">
<select class="form-control form-control-alternative pov_for_subarea" id="pov_for_subarea" name="pov_for_subarea">
<option value=""></option>
#foreach ($provinces as $province)
<option value="{{$province->province_id}}">{{$province->province_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="city_for_subarea">Select City</label>
</div>
<div class="col-md-7">
<select class="form-control form-control-alternative city_for_subarea" id="city_for_subarea" name="city_for_subarea">
<option value=""></option>
</select>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="areaselect">Select Area</label>
</div>
<div class="col-md-7">
<select class="form-control form-control-alternative areaselect" id="areaselect" name="areaselect">
<option value=""></option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="fk_subarea_id">Select Sub-Area</label>
</div>
<div class="col-md-7">
<select class="form-control form-control-alternative fk_subarea_id" id="fk_subarea_id" name="fk_subarea_id">
</select>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="latitude">Latitude</label>
</div>
<div class="col-md-7">
<input type="text" id="latitude" name="latitude" class="form-control form-control-alternative"
placeholder="Latitude">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('latitude')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="longitude">Longitude</label>
</div>
<div class="col-md-7">
<input type="text" id="longitude" name="longitude" class="form-control form-control-alternative"
placeholder="Longitude">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('longitude')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
<div class="row mt-5">
<div class="col-md-6">
<div class="col-md-5">
<label style="font-weight:bold" class="" for="location_string">Location String</label>
</div>
<div class="col-md-7">
<input type="text" id="location_string" name="location_string" class="form-control form-control-alternative"
placeholder="Location String">
</div>
<div class="row" style="text-align:center">
<div class="col-md-8">
#error('location_string')
<span class="ml-auto mr-auto" style="color:red">{{$message}}</span>
#enderror
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
//// this is the controller ////
public function addSchoolBranchInDb(Request $request)
{
// dd($request);
$rules = [
'fk_school_id' => 'required',
'sc_br_name' => 'required',
'sc_br_address' => 'required',
'sc_br_status' => 'required',
'no_of_boys' => 'required',
'no_of_girls' => 'required',
'sc_br_covered_area' => 'required',
'no_of_teachers' => 'required',
'owner_name' => 'required',
'owner_phone' => 'required',
'owner_email' => 'required',
'principal_name' => 'required',
// 'principal_phone' => 'required',
// 'principal_email' => 'required',
// 'fk_subarea_id' => 'required',
// 'latitude' => 'required',
// 'longitude' => 'required',
// 'location_string' => 'required',
];
$messages = [
'fk_school_id.required' => 'School Name is required',
'sc_br_name.required' => 'School Branch Name is required',
'sc_br_address.required' => 'School Address is required',
'sc_br_status.required' => 'School Status is required',
'no_of_boys.required' => 'Number of boys is required',
'no_of_girls.required' => 'Number of girls is required',
'sc_br_covered_area.required' => 'School covered area is required',
'no_of_teachers.required' => 'Number of teachers is required',
'owner_name.required' => 'Owner Name is required',
'owner_phone.required' => 'Owner Phone is required',
'owner_email.required' => 'Owner Email is required',
'principal_name.required' => 'Principal Name is required',
'principal_phone.required' => 'Principal Phone is required',
'principal_email.required' => 'Principal Email is required',
'fk_subarea_id.required' => 'Subarea is required',
'latitude.required' => 'Latitude is required',
'longitude.required' => 'Longitude is required',
'location_string.required' => 'Location String is required',
];
$validator = validator::make($request->all() , $rules );
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
$sc_branch = new Schoolbranch;
$sc_branch->fill($request->all());
$sc_branch->save();
Session::flash('message','School Branch is added');
Session::flash('alert-class', 'alert-success');
return redirect()->back();
}
Ok yes I got the answer from laracast. Alex bouma's answer is right . Just change driver session to file. It works – Tallal just now
I have this problem and I have no idea why it's not working. I have tried so many code changes but I still get the same error when I try to submit a form. It's a simple form to insert data to tomany tables in db. All tables accept data with no error but payment_agrement table gives me this error:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (kassemschool.payment_agrements, CONSTRAINT payment_agrements_responisbleid_foreign FOREIGN KEY (responsible_id) REFERENCES payment_agrements (id)) (SQL: insert into payment_agrements (frais_inscription, payment_mois, Assurance, Garde, Transport, responsible_id, updated_at, created_at) values (450, 550, 400, 200, 300, 154, 2019-11-16 19:47:39, 2019-11-16 19:47:39))
This is my controller:
if(request()->has('rName')) {
$responsible = Responsible::create([
'ResponsibleName'=> $request->rName,
'ResponsibleCNI'=>$request->cni,
'responsible_number'=>$request->tele
]);
}
//Student::create($data);
if(request()->has('MontantP')) {
$payment=Payment::create([
'PaymentPaid'=>$request->MontantP,
'PaymentRemaining'=>$request->RestP,
'responsible_id'=>$responsible->id,
]);
}
if($request->hasFile('file')){
$student->images = $request->file->store('file');
}
if(request()->has('TransportR')) {
$transport=Transport::create([
'TransportPaid'=> $request->TransportP,
'TransportRemainning'=>$request->TransportR,
'TransportDateStart'=>$request->TdateStart,
'TransportDateEnd'=>$request->TdateEnd,
]);
}
if(request()->has('edateStart')) {
$payment_date = Payment_Date::create([
'PaymentDateStart'=>$request->edateStart,
'PaymentDateEnd'=>$request->edateEnd,
'payment_id'=>$payment->id,
]);
$letter = 'KassN';
$number =$request->env . 'G';
$number2 = $request->group;
$id='_'.rand();
$random = $letter.$number.$number2.$id;
if(request()->has('fName')) {
$student = Student::create([
'StudentFName'=> $request->fName,
'StudentLName'=> $request->lName,
'StudentDateStart'=>$request->edateStart,
'StudentDateEnd'=>$request->edateEnd,
'level_id'=> $request->env,
'group_id'=>$request->group,
'responsible_id'=> $responsible->id,
'payment_date_id'=>$payment_date->id,
'Payment_dure_id'=>$request->paymentD,
'payment_id'=>$payment->id,
'transport_id'=>$transport->id,
'student_code'=>$random
]);
}
if(request()->has('inscription')){
$agrement= Payment_agrement::create([
'frais_inscription'=>$request->inscription,
'payment_mois'=>$request->payment,
'Assurance'=>$request->assaurance,
'Garde'=>$request->garde,
'Transport'=>$request->fraiTransport,
'responsible_id'=>$responsible->id
]);
}
my create view
#extends('layouts.app')
#section('content')
#if (Route::has('login'))
#auth
#if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
back to <strong>Home</strong>
back to <strong>list</strong>
</div>
#endif
<div class="mr-auto offset-md-1" style="width: 200px;">
<input type="button" class="btn btn-danger btn-sm" name="" value="<- Reteur">
</div>
<div class="card-body">
<div class="container" style="width: 80%;">
<form action="{{url('student')}}" method="POST">
{{ csrf_field() }}
<div class="form-group">
<label for="firstName">First Name </label>
<input type="text" class="form-control" name="fName" id="elastName">
</div>
<div class="form-group">
<label for="lastName">Last name:</label>
<input type="text" class="form-control" name="lName" id="efirstName">
</div>
<div class="form-group">
<label for="responsable">Responsable Name:</label>
<input type="text" class="form-control" name="rName" id="responsable">
</div>
<div class="form-group">
<label for="cni">Responsable CNI:</label>
<input type="text" class="form-control" name="cni" id="cni">
</div>
<div class="form-group">
<label for="nuveau">Niveau:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="nuveau">Options</label>
</div>
<select class="custom-select" id="nuveau" name="env">
<option selected>Choose...</option>
#foreach($levels as $level)
<option value="{{$level->id}}">{{$level->LevelName}} </option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<fieldset>
<legend>Aggrement:<hr></legend>
<div class="form-group">
<label for="cni">Frais de inscription:</label>
<input type="text" class="form-control" name="inscription" id="cni">
</div>
<div class="form-group">
<label for="cni">paiement mensuel:</label>
<input type="text" class="form-control" name="payment" id="cni">
</div>
<div class="form-group">
<label for="cni">Frais de Assurance:</label>
<input type="text" class="form-control" name="assaurance" id="cni">
</div>
<div class="form-group">
<label for="cni">Frais de Garde:</label>
<input type="text" class="form-control" name="garde" id="cni">
</div>
<div class="form-group">
<label for="cni">Frais de transport:</label>
<input type="text" class="form-control" name="fraiTransport" id="cni">
</div>
</fieldset>
</div>
<div class="form-group">
<label for="nuveau">Group:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="group">Options</label>
</div>
<select class="custom-select" id="nuveau" name="group">
<option selected>Choose...</option>
#foreach($groups as $group)
<option value="{{$group->id}}">{{$group->group_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="payment">Payment:</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="payment">Options</label>
</div>
<select class="custom-select" id="payment" name="paymentD">
<option selected>Choose...</option>
#foreach($payment_dures as $payment_dure)
<option value="{{$payment_dure->id}}">{{$payment_dure->payment_dure_name}}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="dateStart"></label>
<input type="date" class="#" id="dateStart" style="width: 49%;" name="edateStart">
<label for="dateEnd">au:</label>
<input type="date" class="#" id="dateEnd" style="width: 44%;" name="edateEnd">
</div>
<div class="form-group">
<label for="MontantP">Montant paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" name="MontantP" placeholder="" id="MontantP">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<div class="form-group">
<label for="RestP">Rest a paye paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="" id="MontantR" name="RestP">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1" style="width: 100%">Bus subscribtion</a>
<div class="row">
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card card-body">
<div class="form-group">
<div class="form-group">
<label for="TMontantP">Montant paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="" id="TMontantP" name="TransportP">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<div class="form-group">
<label for="TRestP">Rest a paye paye:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="" id="TRestP" name="TransportR">
<div class="input-group-append">
<span class="input-group-text">DH</span>
</div>
</div>
</div>
<div class="form-group">
<label for="TdateStart"></label>
<input type="date" class="#" id="TdateStart" style="width: 48%;" name="TdateStart">
<label for="dTateEnd">au:</label>
<input type="date" class="#" id="TdateEnd" style="width: 44%;" name="TdateEnd">
</div>
</div>
</div>
</div>
</div>
</div>
</p>
<br>
<button type="submit" class="btn btn-secondary">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
#else
<div class="d-flex justify-content-center text-center">
<div class="alert alert-danger" role="alert" style="width: 70%">
identifié vous d'abord
</div>
</div>
#endauth
#endif
#endsection
Looks like your foreign key constraint isn't setup correctly. From the look of the error you have setup payment_agrements.responsible_id to point to payment_agrements.id instead of responsibles.id.
In the migration for that table, that field probably looks like this:
$table->foreign('responsible_id')->references('id')->on('payment_agrements');
When it should be:
$table->foreign('responsible_id')->references('id')->on('responsibles');
I'm using bootstrap-vue in my laravel project to pass data from the view to the database with checkboxes (b-form-checkbox), i want to select from the permissions passed from the database and assign it to a role, which means a role can have more than one permission, unfortunately the data is not persisting to the database as an array because if i select more than one in the checkbox it only shows the first one clicked. Please i need help as i have spent too much time on this issue. This is my code:
edit.blade.php
#extends('layouts.master')
#section('content')
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Admin
<small>Edit</small>
</h1>
<ol class="breadcrumb">
<li><i class="fa fa-dashboard"></i> Home</li>
<li>Role</li>
<li class="active">Edit</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
#include('layouts.partials.message')
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="boxtitle">Edit Role</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<form action="{{ route('role.update', ['id' => $role->id]) }}" enctype="multipart/form-data" method="post" accept-charset="utf-8">
{{csrf_field()}}
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="display_name" value="{{ old('display_name', $role->display_name) }}" class="form-control" placeholder="Name (Human Readable)" required>
<span class="help-block text-red">
#if($errors->has('display_name'))
{{ $errors->first('display_name')}}
#endif
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="name" value="{{ old('name', $role->name) }}" class="form-control" placeholder="Slug (can not be edited)" disabled>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<input type="text" name="description" value="{{ old('description', $role->description) }}" class="form-control" placeholder="Role Description">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h2>Permissions:</h2>
<b-form-group>
<b-form-checkbox-group v-model="permissionsSelected">
#foreach ($permissions as $permission)
<div class="form-group">
<b-form-checkbox id="permissions" name="permissions" value="{{ $permission->id }}">
<div class="form-group">
{{ $permission->display_name }} <em> ({{ $permission->description }})</em>
</div>
</b-form-checkbox>
</div>
#endforeach
</div>
</div>
<hr>
<div class="row">
<div class="col-md-1">
<div class="form-group">
<button class="btn btn-primary" type="submit" id="submit">
<i class="fa fa-check"></i> Submit
</button>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</div>
</div>
<div class="col-md-11">
<div class="form-group">
<div class="checkbox">
<label>
<input name="redirect" type="checkbox" checked> Redirect to role list after submission
</label>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
</div>
</section>
#endsection
#section('vue')
<script>
var app = new Vue ({
el: '#app',
data: {
permissionsSelected: {!!$role->permissions->pluck('id')!!}
}
});
</script>
#endsection
I'm trying to upload a file with Laravel but it does not work
I will send the field with the meta name view
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane fade in active" id="tab1success">
<form method="post" name="type" action="songs">
{{ csrf_field() }}
<div class="form-group">
<div class="row">
<label class="col-md-3 control-label" for="Name">نام موزیک</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-music">
</i>
</div>
<input id="Name" name="title" type="text"
placeholder="نام موزیک" class="form-control input-md">
</div>
</div>
</div>
<br>
<div class="row">
<label class="col-md-3 control-label" for="Name (Full name)">دسته
بندی</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-list">
</i>
</div>
<select id="Name" name="category" type="دسته بندی"
placeholder="دسته بندی" class="form-control input-md">
<option>fun</option>
<option>love</option>
<option>birth</option>
<option>wedding</option>
</select>
</div>
</div>
</div>
<br>
<div class="row">
<label class="col-md-3 control-label" for="Name (Full name)">توضیحات</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-file-text-o">
</i>
</div>
<textarea id="Name" name="text" placeholder="توضیحات"
class="form-control input-md"></textarea>
</div>
</div>
</div>
<br>
<div class="row">
<label class="col-md-3 control-label" for="Name (Full name)">انتخاب
فایل</label>
<div class="col-md-7">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-folder-o">
</i>
</div>
<input id="meta" name="meta" type="file" placeholder="انتخاب فایل"
class="form-control input-md">
</div>
</div>
</div>
<br>
<div class="row" style="text-align: center">
<div class="col-md-10 " style="text-align: center">
<button id="Name" name="submit" type="submit" placeholder="انتخاب فایل"
class="form-control input-md" style="text-align: center">اضافه
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
Controller
public function create(Request $req, $type) {
$this->authorize('is_admin');
$req->file('meta')->store('app');
// $path = Storage::putFile('app', $req->file('meta'))
}
error
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to a member function store() on null
Here is an image of the error
Does anybody know what i should do about this?
Add enctype="multipart/form-data" to your <form> tag in your blade:
<form method="post" name="type" action="songs" enctype="multipart/form-data">
Based on your blade file you can see that the file meta being uploaded is not required, so in your controller, you need to check if the file was sent before calling the store method on it. Check this:
public function create(Request $req, $type) {
$this->authorize('is_admin');
$file = $req->file('meta') ? $req->file('meta')->store('app') : null;
}