how to make selected option using enum in laravel? - laravel

this is my code, how to make the selected option value in the edit form using enum data in the database? this is not working it just view the select option, not with id-data
this the code blade
<!-- Modal edit -->
#foreach($daftar_pelanggan as $pelanggan)
<div class="modal fade" id="editModal-{{ $pelanggan->id }}" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title mb-0" id="editModalLabel">Update Data Pelanggan</h5>
</div>
<div class="modal-body">
<!-- Card body -->
<form role="form" action="{{ route('daftar_pelanggan.update') }}" method="POST" id="editForm">
#csrf
#method('PUT')
<!-- Input groups with icon -->
<div class="form-group row">
<label for="updateNamaPelanggan" class="col-md-2 col-form-label form-control-label">Nama</label>
<div class="col-md-10">
<input type="hidden" name="id" value="{{ $pelanggan->id }}">
<input class="form-control" type="nama" value="{{ $pelanggan->nama_pelanggan }}" id="updateNamaPelanggan" name="updateNamaPelanggan" required >
</div>
</div>
<div class="form-group row">
<label for="updateAlamat" class="col-md-2 col-form-label form-control-label">Alamat</label>
<div class="col-md-10">
<input class="form-control" type="alamat" value="{{ $pelanggan->alamat }}" id="updateAlamat" name="updateAlamat" required>
</div>
</div>
<div class="form-group row">
<label for="updateNoTelp" class="col-md-2 col-form-label form-control-label">No.Telp</label>
<div class="col-md-10">
<input class="form-control" type="notelp" value="{{ $pelanggan->no_telp }}" id="updateNoTelp" name="updateNoTelp" required>
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<div class="form-group">
<label class="form-control-label" for="updatePoin">POIN</label>
<input type="text" class="form-control" value="{{ $pelanggan->poin }}" id="updatePoin" name="updatePoin">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-control-label" for="status_member">Kategori</label>
<select class="form-control" id="status_member" name="status_member" required="required">
<option value="" disabled selected>- Pilih -</option <option value="silver"{{($pelanggan->status_member === 'silver') ? 'selected' : '' }} >Silver</option>
<option value="gold" {{ ($pelanggan->status_member === 'gold'? 'selected' : '')}}>Gold</option>
<option value="diamond" {{($pelanggan->status_member === 'diamond')? 'selected' : ''}}>Diamond</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="reset" class="btn btn-secondary" data-dismiss="modal">Reset</button>
<button type="submit" class="btn btn-primary">Update Data</button>
</div>
</form>
</div>
</div>
</div>
#endforeach
this is select code this is not working what's wrong with this code?
<option value="" disabled selected>- Pilih -</option <option value="silver"{{($pelanggan->status_member === 'silver') ? 'selected' : '' }} >Silver</option>
<option value="gold" {{ ($pelanggan->status_member === 'gold'? 'selected' : '')}}>Gold</option>
<option value="diamond" {{($pelanggan->status_member === 'diamond')? 'selected' : ''}}>Diamond</option>
</select>
and i edit with this still not working what's wrong with this code?
<select class="form-control" id="status_member-" name="status_member" required="required">
#if($pelanggan->status_member == "silver")
<option value="silver" selected="selected">Silver</option>
<option value="gold">Gold</option>
<option value="diamond">Diamond</option>
#elseif($pelanggan->status_member == "gold")
<option value="silver">Silver</option>
<option value="gold" selected="selected">Gold</option>
<option value="diamond">Diamond</option>
#else
<option value="silver">Silver</option>
<option value="gold" >Gold</option>
<option value="diamond" selected="selected">Diamond</option>
#endif
</select>

Related

Undefined array key "school_name" using flatMap

i am using flatMap to get the keys and the value related together
but it gives me an error Undefined array key "school_name" i dont know why
although i do return $setting it gives me like this
{
setting: {
current_session: "2021-2022",
school_title: "MS",
school_name: "Mora Soft International Schools",
end_first_term: "01-12-2021",
end_second_term: "01-03-2022",
phone: "0123456789",
address: "القاهرة",
school_email: "info#morasoft.com",
logo: "1.jpg"
}
}
this is my table settings table
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key');
$table->string('value');
$table->timestamps();
});
and this is my web.php route
Route::resource('settings', 'SettingController');
and here is my settingcontroller
/**
* Display a listing of the resource.
*
* #return \Illuminate\Http\Response
*/
public function index()
{
$collection = setting::all();
$setting['setting'] = $collection->flatMap(function ($collection){
return [$collection->key => $collection->value];
});
// return $setting;
return view('pages.settings.index',compact('setting'));
}
and here is my blade that views the form
<form enctype="multipart/form-data" method="post" action="{{route('settings.update','test')}}">
#csrf #method('PUT')
<div class="row">
<div class="col-md-6 border-right-2 border-right-blue-400">
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">اسم المدرسة<span class="text-danger">*</span></label>
<div class="col-lg-9">
<input name="school_name" value="{{ $setting['school_name'] }}" required type="text" class="form-control" placeholder="Name of School">
</div>
</div>
<div class="form-group row">
<label for="current_session" class="col-lg-2 col-form-label font-weight-semibold">العام الحالي<span class="text-danger">*</span></label>
<div class="col-lg-9">
<select data-placeholder="Choose..." required name="current_session" id="current_session" class="select-search form-control">
<option value=""></option>
#for($y=date('Y', strtotime('- 3 years')); $y<=date('Y', strtotime('+ 1 years')); $y++)
<option {{ ($setting['current_session'] == (($y-=1).'-'.($y+=1))) ? 'selected' : '' }}>{{ ($y-=1).'-'.($y+=1) }}</option>
#endfor
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">اسم المدرسة المختصر</label>
<div class="col-lg-9">
<input name="school_title" value="{{ $setting['school_title'] }}" type="text" class="form-control" placeholder="School Acronym">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">الهاتف</label>
<div class="col-lg-9">
<input name="phone" value="{{ $setting['phone'] }}" type="text" class="form-control" placeholder="Phone">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">البريد الالكتروني</label>
<div class="col-lg-9">
<input name="school_email" value="{{ $setting['school_email'] }}" type="email" class="form-control" placeholder="School Email">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">عنوان المدرسة<span class="text-danger">*</span></label>
<div class="col-lg-9">
<input required name="address" value="{{ $setting['address'] }}" type="text" class="form-control" placeholder="School Address">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">نهاية الترم الاول </label>
<div class="col-lg-9">
<input name="end_first_term" value="{{ $setting['end_first_term'] }}" type="text" class="form-control date-pick" placeholder="Date Term Ends">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">نهاية الترم الثاني</label>
<div class="col-lg-9">
<input name="end_second_term" value="{{ $setting['end_second_term'] }}" type="text" class="form-control date-pick" placeholder="Date Term Ends">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label font-weight-semibold">شعار المدرسة</label>
<div class="col-lg-9">
<div class="mb-3">
<img style="width: 100px" height="100px" src="{{ URL::asset('attachments/logo/'.$setting['logo']) }}" alt="">
</div>
<input name="logo" accept="image/*" type="file" class="file-input" data-show-caption="false" data-show-upload="false" data-fouc>
</div>
</div>
</div>
</div>
<hr>
<button class="btn btn-success btn-sm nextBtn btn-lg pull-right" type="submit">{{trans('Students_trans.submit')}}</button>
</form>

Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given

I have a form to submit add salarie, the problem here if I delete the function store in controller, it even gives me error instead of giving me error function store does not exist.
SalarieController.php
public function store(request $request){
Salarie::create($request->all());
session()->flash('success','salarie add successfully');
return redirect('salaries');
}
web.php
Route::resource('salaries', 'SalarieController');
create.blade.php
<form action="{{ url('salaries') }}" method="post">
{{ csrf_field() }}
<div class="col-md-12">
<div class="form-group col-md-3 #if($errors->get('matricule')) has-error #endif">
<input type="text" name="matricule" class="form-control" value="{{ old('matricule') }}" placeholder="matricule">
</div>
<div class="form-group col-md-3 #if($errors->get('nom')) has-error #endif">
<input type="text" name="nom" class="form-control" value="{{ old('nom') }}" placeholder="nom">
</div>
<div class="form-group col-md-3 #if($errors->get('prenom')) has-error #endif">
<input type="text" name="prenom" class="form-control" value="{{ old('prenom') }}" placeholder="prenom">
</div>
<div class="form-group col-md-3 #if($errors->get('cin')) has-error #endif">
<input type="text" name="cin" class="form-control" value="{{ old('cin') }}" placeholder="cin">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3 ">
<input type="date" name="daten" class="form-control" value="{{ old('daten') }}" placeholder="date naissance">
</div>
<div class="form-group col-md-3">
<select class="form-control" name="situationf">
<option>celebataire</option>
<option>marie</option>
</select>
</div>
<div class="form-group col-md-3">
<input type="text" name="nbree" class="form-control" value="{{ old('nbree') }}" placeholder="nombre d'enfant">
</div>
<div class="form-group col-md-3">
<input type="text" name="cnss" class="form-control" value="{{ old('cnss') }}" placeholder="matricule CNSS">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3 #if($errors->get('salairenet')) has-error #endif">
<input type="text" name="salairenet" class="form-control" value="{{ old('salairenet') }}" placeholder="salaire net">
</div>
<div class="form-group col-md-3 #if($errors->get('unite')) has-error #endif">
<select class="form-control" name="unite">
<option>Heure</option>
<option>Jour</option>
<option>Mois</option>
</select>
</div>
<div class="form-group col-md-3">
<input type="text" name="hs" class="form-control" value="{{ old('hs') }}" placeholder="tarif HS">
</div>
<div class="form-group col-md-3">
<input type="date" name="datee" class="form-control" value="{{ old('datee') }}" placeholder="date embouche">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3">
<select class="form-control" name="fonction_id">
<option></option>
#foreach($fonctions as $fonction)
<option value="{{ $fonction->id }}">{{ $fonction->fonction}}</option>
#endforeach
</select>
</div>
<div class="form-group col-md-3">
<input type="text" name="primer" class="form-control" value="{{ old('primer') }}" placeholder="prime rendement">
</div>
<div class="form-group col-md-3">
<input type="text" name="primel" class="form-control" value="{{ old('primel') }}" placeholder="prime de longement">
</div>
<div class="form-group col-md-3">
<input type="text" name="primet" class="form-control" value="{{ old('primet') }}" placeholder="prime de transport">
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3">
<select class="form-control" name="chantier_id">
<option></option>
#foreach($chantiers as $chantier)
<option value="{{ $chantier->id }}">{{ $chantier->chantier}}</option>
#endforeach
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-2 col-md-offset-5">
<button type="submit" class="btn btn-theme btn-lg" value="submit">Ajouter</button>
</div>
</div>
</form>
Salarie.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Salarie extends Model
{
public function chantier(){
return $this->belongsTo('App\Chantier');
}
protected $guarded = [];
}
I guess you're missing some options values
here
<select class="form-control" name="situationf">
<option>celebataire</option> // must be <option value="celeb_value">celebataire</option>
<option>marie</option> // must be <option value="marie_value">celebataire</option>
</select>
here also
<select class="form-control" name="unite">
<option>Heure</option> // must be <option value="heure_value">Heure</option>
<option>Jour</option> // must be <option value="jour_value">Jour</option>
<option>Mois</option> // must be <option value="mois_value">Mois</option>
</select>
here too
<select class="form-control" name="fonction_id">
<option></option> // remove empty option or set function_id to nullable
#foreach($fonctions as $fonction)
<option value="{{ $fonction->id }}">{{ $fonction->fonction}}</option>
#endforeach
</select>
and here
<select class="form-control" name="chantier_id">
<option></option> // same as function_id
#foreach($chantiers as $chantier)
<option value="{{ $chantier->id }}">{{ $chantier->chantier}}</option>
#endforeach
</select>

Use row data to be inserted into table and update current table Laravel 5.7

I use record data from a table to reduce the entries that the user will make as it will be stored in another table, but after saving it must update the status of the current record to be 'Used'
the current row is in table called airfiles and will be inserted after adding sale amount into table called tickets
here is the airfiles schema code :
public function up()
{
Schema::create('airfiles', function (Blueprint $table) {
$table->increments('id');
$table->string('airl')->nullable();
$table->string('num')->nullable();
$table->date('date')->nullable();
$table->string('pass')->nullable();
$table->string('route')->nullable();
$table->string('dot')->nullable();
$table->string('dor')->nullable();
$table->string('flynumt')->nullable();
$table->string('flynumr')->nullable();
$table->float('fare')->nullable();
$table->float('tax')->nullable();
$table->float('total')->nullable();
$table->float('comm')->nullable();
$table->float('net')->nullable();
$table->string('rloc')->nullable();
$table->string('son')->nullable();
$table->string('acc')->nullable();
$table->string('pcc')->nullable();
$table->tinyInteger('progid')->default('1');
$table->string('status')->nullable();
$table->integer('segment')->nullable();
$table->string('filename')->nullable();
$table->float('k7')->nullable();
$table->string('used')->nullable();
$table->string('transfer')->nullable();
$table->integer('ticket_id')->unsigned()->nullable();
$table->rememberToken();
$table->timestamps();
});
Schema::table('airfiles', function (Blueprint $table) {
$table->foreign('ticket_id')->references('id')->on('tickets')->onDelete('cascade');
});
}
and here is the TicketController code:
public function store(Request $request, $id)
{
$this->validate($request,[
'date'=>'required',
'tkt_no'=>'required',
'sector'=>'required',
'airline'=>'required',
'supplier'=>'required',
'fare'=>'required',
'tax'=>'required',
'total_tax'=>'required',
'total_cost'=>'required',
'k7'=>'required',
'comm'=>'required',
'profit'=>'required',
'sale_price'=>'required',
'sign'=>'required',
'pax_name'=>'required',
'mob'=>'required',
'amount_arabic'=>'required',
'amount_english'=>'required',
'action_type'=>'required',
'trans_type'=>'required',
'payment_type'=>'required',
]);
$ticket = new Ticket();
$ticket->date = $request->get('date');
$ticket->tkt_no = $request->get('tkt_no');
$ticket->sector = $request->get('sector');
$ticket->airline = $request->get('airline');
$ticket->supplier = $request->get('supplier');
$ticket->fare = $request->get('fare');
$ticket->tax = $request->get('tax');
$ticket->total_tax = $request->get('total_tax');
$ticket->total_cost = $request->get('total_cost');
$ticket->k7 = $request->get('k7');
$ticket->comm = $request->get('comm');
$ticket->profit = $request->get('profit');
$ticket->sale_price = $request->get('sale_price');
$ticket->sign = $request->get('sign');
$ticket->branch =Auth::user()->branch_id;
$ticket->pax_name = $request->get('pax_name');
$ticket->mob = $request->get('mob');
$ticket->amount_arabic = $request->get('amount_arabic');
$ticket->amount_english = $request->get('amount_english');
$ticket->action_type = $request->get('action_type');
$ticket->trans_type = $request->get('trans_type');
$ticket->payment_type = $request->get('payment_type');
$ticket->post_flag = '0';
$ticket->save();
Airfile::find($id)->update(['used' => 'Used']);
session()->flash('success',__('site.added_successfully'));
return redirect()->route('$tickets.index');
}
here is the close blade code :
<div class="card-content collpase show">
<div class="card-body">
<form action="{{ route('tickets.store') }}" method="post">
{{ csrf_field() }}
{{ method_field('post') }}
<div class="row">
<div class="form-group col-md-2">
<label>#lang('site.son')</label>
#if(Auth::user()->shortsign == '--')
<select class="select2-size-lg form-control border-primary"
style="width: 100%;" name="sign">
#foreach ($users as $user)
<option
value="{{ $user->shortsign }}">{{ $user->shortsign }}</option>
#endforeach
</select>
#else
<select class="select2-size-lg form-control border-primary"
style="width: 100%;" name="sign" readonly>
<option
value="{{ Auth::user()->shortsign }}">{{ Auth::user()->shortsign }}</option>
</select>
#endif
</div>
<div class="col-md-3">
<div class="form-group">
<label for="pax_name">#lang('site.pax_name')</label>
<div class="position-relative has-icon-left">
<input type="text" id="pax_name" class="form-control"
name="pax_name"
value="{{ $airfiles->pass }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="client">#lang('site.client')</label>
<div class="position-relative has-icon-left">
<input type="text" id="client" class="form-control"
name="client"
value="{{ $airfiles->pass }}">
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="mob">#lang('site.mob')</label>
<div class="position-relative has-icon-left">
<input type="text" id="mob" class="form-control"
name="mob"
value="{{ old('mob') }}">
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="form-group col-md-2">
<label>#lang('site.supplier')</label>
<select class="form-control select2 status-type" style="width: 100%;"
name="supplier"
id="supplier">
<option selected value="bsp">BSP</option>
<option value="online">Online</option>
</select>
</div>
<div class="form-group col-md-2">
<label>#lang('site.action_type')</label>
<select class="form-control select2 status-type" style="width: 100%;"
name="action_type"
id="action_type">
<option selected value="issue">#lang('site.issue')</option>
<option value="reissue">#lang('site.reissue')</option>
<option value="emd">#lang('site.emd')</option>
<option value="refund">#lang('site.refund')</option>
{{-- <option value="void_charge">#lang('site.void_charge')</option>--}}
</select>
</div>
<div class="form-group col-md-2">
<label>#lang('site.trans_type')</label>
<select class="form-control select2 status-type" style="width: 100%;"
name="trans_type"
id="trans_type">
<option selected value="domestic">#lang('site.domestic')</option>
<option value="international">#lang('site.international')</option>
</select>
</div>
<div class="form-group col-md-2">
<label>#lang('site.payment_type')</label>
<select class="form-control select2 status-type" style="width: 100%;"
name="payment_type"
id="payment_type">
<option selected value="cash">#lang('site.cash')</option>
<option value="credit">#lang('site.credit')</option>
<option value="advance">#lang('site.advance')</option>
<option value="pending">#lang('site.pending')</option>
</select>
</div>
<div class="form-group col-md-2">
<label>#lang('site.airline')</label>
<select class="form-control select2 status-type" style="width: 100%;"
name="airline"
id="airline">
#foreach ($airlines as $airline)
<option value="{{ $airline->code }}">{{ $airline->code }}</option>
#endforeach
</select>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="sale_price">#lang('site.sale_price')</label>
<div class="position-relative has-icon-left">
<input type="text" id="sale_price" class="form-control"
name="sale_price" placeholder="0"
onkeypress="return isNumberKey(event)"
{{-- onblur="findTotal()"--}}
onkeyup="main ();eng_main();findTotal()"
value=" {{ old('sale_price') }}">
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="tkt_no">#lang('site.tkt_no')</label>
<div class="position-relative has-icon-left">
<input type="text" id="tkt_no" class="form-control"
name="tkt_no" onkeypress="return isNumberKey(event)"
value="{{ $airfiles->num }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="rloc">#lang('site.rloc')</label>
<div class="position-relative has-icon-left">
<input type="text" id="rloc" class="form-control"
name="rloc"
value="{{ $airfiles->rloc }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="sector">#lang('site.sector')</label>
<div class="position-relative has-icon-left">
<input type="text" id="sector" class="form-control"
name="sector" placeholder="#lang('site.like') : HAS/JED JED/MAA"
value="{{ $airfiles->route }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="fare">#lang('site.fare')</label>
<div class="position-relative has-icon-left">
<input type="text" id="fare" class="form-control "
onblur="findTotal()"
name="fare" placeholder="0"
{{-- onkeyup="main ()"--}}
value="{{ $airfiles->fare }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="tax">#lang('site.tax')</label>
<div class="position-relative has-icon-left">
<input type="text" id="tax" class="form-control"
name="tax" placeholder="0"
onkeypress="return isNumberKey(event)"
onblur="findTotal()"
{{-- onkeyup="return sum(event)"--}}
value="{{ $airfiles->tax }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="k7">#lang('site.k7')</label>
<div class="position-relative has-icon-left">
<input type="text" id="k7" class="form-control"
name="k7" placeholder="0"
onkeypress="return isNumberKey(event)"
onblur="findTotal()"
{{-- onkeyup="return sum(event)"--}}
value="{{ $airfiles->k7 }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="comm">#lang('site.comm')</label>
<div class="position-relative has-icon-left">
<input type="text" id="comm" class="form-control"
name="comm" placeholder="0"
onkeypress="return isNumberKey(event)"
onblur="findTotal()"
{{-- onkeyup="return sum(event)"--}}
value="{{ $airfiles->comm }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="profit">#lang('site.profit')</label>
<div class="position-relative has-icon-left">
<input type="number" id="profit" class="form-control"
name="profit" placeholder="0"
onkeypress="return isNumberKey(event)"
onblur="findTotal()"
{{-- onkeyup="return sum(event)"--}}
value="{{ number_format(old('profit'), 2) }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="total_tax">#lang('site.total_tax')</label>
<div class="position-relative has-icon-left">
<input type="text" id="total_tax" class="form-control"
name="total_tax" placeholder="0"
onkeypress="return isNumberKey(event)"
onkeyup="return sum(event)"
value="{{ old('total_tax') }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="total_cost">#lang('site.total_cost')</label>
<div class="position-relative has-icon-left">
<input type="text" id="total_cost" class="form-control"
name="total_cost" placeholder="0"
onkeypress="return isNumberKey(event)"
onkeyup="return sum(event)"
value="{{ old('total_cost') }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<label for="date">#lang('site.date')</label>
<div class="input-group">
<input id="date" name="date" class="form-control datepicker" type="date"
value="{{ $airfiles->date }}" readonly>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="amount_arabic">#lang('site.amount_arabic')</label>
<div class="position-relative has-icon-left">
<input type="text" id="amount_arabic" class="form-control"
name="amount_arabic"
onkeypress="return isNumberKey(event)"
onkeyup="return sum(event)"
value=" {{ old('amount_arabic') }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="amount_english">#lang('site.amount_english')</label>
<div class="position-relative has-icon-left">
<input type="text" id="amount_english" class="form-control"
name="amount_english"
onkeypress="return isNumberKey(event)"
onkeyup="return sum(event)"
value=" {{ old('amount_english') }}" readonly>
<div class="form-control-position">
<i class="la la-keyboard-o"></i>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions right">
<button id="slide-toast" type="submit"
class="btn btn-outline-warning btn-min-width box-shadow-2 mr-1 mb-1"><i
class="la la-check-square-o"></i> #lang('site.close')</button>
</div>
</form><!-- end of form -->
</div><!-- end of box -->
</div>
here is the route code :
//airfile routes
Route::resource('airfiles', 'AirfileController')->except(['show']);
//ticket routes
Route::resource('tickets', 'TicketController')->except(['show']);
the error i got is :
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Too few arguments to function App\Http\Controllers\TicketController::store(), 1 passed and exactly 2 expected
any one can help ?
This is because this methods expects an ID and may be you did not pass id from route to this method. you can pass id to route like this:
{{ route('routeName', ['id' => 1]) }}
And make your route like this:
Route::get('appName/{id}', ControllerName#store)->name('routeName');

button not responding laravel

i have this page where i have form where the action url are same. My second form work perfectly fine but mu first form doesn't responding when i hit the button or <a>. I've try to switch the <form action="{{url('purchase')}}" method="post") between form, i've try to cut the action on second form and move it to first form still no luck... any idea? here's sum of my code
<form class="px-2 py-2" action="{{ url('purchase') }}" method="post">
{{csrf_field()}}
<div id="items">
</div>
<div class="row mx-1 px-2">
Purchase
</div>
</form>
that's my first form, inside of id="items" purposely empty since i fill it up with javascript
<form id="newItemForm" style="display:none;">
<div class="form-group row" id="item">
<label for="invoice" class="col-sm-2 col-form-label">Supplier</label>
<div class="col-sm-2">
<select class="form-control" onchange="newExisting(this)">
<option value="#" selected>Choose Supplier</option>
<option value="existing">Existing Supplier</option>
<option value="new">New Supplier</option>
</select>
</div>
<div class="col-sm-8" id="existingCompany" style="display:none;">
<div class="row">
<div class="col-sm-4">
<select class="form-control" name="fromE" onchange="localImport(this)">
<option value="#" checked>From</option>
<option value="f" checked>Import</option>
<option value="l" checked>Local</option>
</select>
</div>
<div class="col-sm-8">
<select class="form-control" name="supplier" id="supplierID">
<option value="#">Choose Company</option>
</select>
</div>
</div>
</div>
<div class="col-sm-8" style="display:none;" id="newCompany">
<div class="row">
<div class="col-sm-4">
<select class="form-control" name="fromN">
<option value="#" checked>From</option>
<option value="f" checked>Import</option>
<option value="l" checked>Local</option>
</select>
</div>
<div class="col-sm-4">
<input type="text" name="kind" value="" placeholder="PT, CV, FIRMA" class="form-control">
</div>
<div class="col-sm-4">
<input type="text" name="supplierName" placeholder="Company Name" class="form-control">
</div>
</div>
</div>
</div>
<div id="newItems">
<div class="form-group row" id="item">
<label for="invoice" class="col-sm-2 col-form-label">Item Name</label>
<div class="col-sm-10">
<input type="text" name="item0" class="form-control" placeholder="Item Name" onkeyup="getCompanyGoods(this)">
<span class="text text-danger" style="display:none;" id="existsWarning0">*Item already exists</span>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="taxInvoice">QTY<span class="text-danger">*</span></label>
<input type="number" name="qty0" class="form-control" id="qty0" required onkeyup="calculate(this)">
</div>
<div class="form-group col-md-3">
<label for="inputPassword4">Units<span class="text-danger">*</span></label>
<input type="number" name="units0" class="form-control" id="units0" required onkeyup="calculate(this)">
</div>
<div class="form-group col-md-3">
<label for="inputPassword4">Total</label>
<div class="form-controll font-weight-bold" style="font-size:x-large;" id="total0">IDR0.00</div>
</div>
</div>
</div>
<label class="btn btn-primary" id="newRow" onclick="addRow()">+ Item</label>
<input type="hidden" name="type" value="new">
<input type="hidden" name="nore" value="#" id="nore">
<input type="number" name="totalItem" value="0" id="totalItem">
<button name="button" class="btn btn-danger float-right" >Purchase</button>
</form>
this is my second form and it work perfectly....
Change
Purchase
to
<button type='submit'>Purchase</button>
Because you have used a tag instead of button type "submit"
Purchase
Change it to like this
<button class="btn btn-primary" type="submit"> Purchase </button>

Only retrieving last option in multiple select element

The form is posted and I'm retrieving the inputs with:
$inputs = Input::all();
return Response::json($inputs);
The form is like this:
<form role="form" method="POST" action="/account/enrollments/{{ $activity->id }}/update" class="form-horizontal" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="row">
<div class="col-xs-12 col-md-4">
<h4>Available Students</h4>
<select multiple class="form-control" name="available">
#foreach ($available as $student)
<option value="{{ $student->id }}">{{ $student->firstname }} {{ $student->lastname }}</option>
#endforeach
</select>
</div>
<div class="col-xs-12 col-md-4 push-top">
<button name="enrol" class="btn btn-block btn-effect-ripple btn-primary">Enrol Student(s)</button>
<button name="unenrol" class="btn btn-block btn-effect-ripple btn-warning">Remove Student(s)</button>
</div>
<div class="col-xs-12 col-md-4">
<h4>Currently Enrolled Students</h4>
<select multiple class="form-control" name="enrolled">
#foreach ($enrolled as $student)
<option value="{{ $student->id}}">{{ $student->firstname }} {{ $student->lastname }}</option>
#endforeach
</select>
</div>
</div>
</form>
But the response only shows the id of the last one selected. So, if I select three from the available select, it only returns the id of the last one, like this:
{
"_token": "KOqUu3m0uxwNxPC1BVisFT2y6P86z3uoBqZiEgTa",
"available": "5",
"enrol": ""
}
How do I retrieve all three inputs?
Here's the actual HTML from source:
<form role="form" method="POST" action="/account/enrollments/1/update" class="form-horizontal" autocomplete="off">
<input type="hidden" name="_token" value="KOqUu3m0uxwNxPC1BVisFT2y6P86z3uoBqZiEgTa">
<div class="row">
<div class="col-xs-12 col-md-4">
<h4>Available Students</h4>
<select multiple class="form-control" name="available">
<option value="2">Student 2</option>
<option value="4">Student 4</option>
<option value="5">Student 5</option>
</select>
</div>
<div class="col-xs-12 col-md-4 push-top">
<button name="enrol" class="btn btn-block btn-effect-ripple btn-primary">Enrol Student(s)</button>
<button name="unenrol" class="btn btn-block btn-effect-ripple btn-warning">Remove Student(s)</button>
</div>
<div class="col-xs-12 col-md-4">
<h4>Currently Enrolled Students</h4>
<select multiple class="form-control" name="enrolled">
<option value="3">Student 3</option>
</select>
</div>
</div>
</form>
It seems that you have to put[] in the name value:
name="available[]"
Then it returns an array.

Resources