Laravel 8 throws undefined offset how to handle it? - php

here I have form to retrieve data from database using date and time issue is iam able to retrive data succesfuly most times but some time i get this error
here is the code
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\PricingDetail;
use App\AccessoryCharge;
use App\Discount;
use App\MonthlyCourtCharge;
class PricingDetailController extends Controller
{
public function index(Request $request){
$op_id=$request->session()->get('op_id');
$inf_id=$request->session()->get('inf_id');
if(is_null($inf_id)){
return redirect('/infrastructure_details');
}else if(is_null($op_id)){
return redirect('/operational_details');
}else{
$timings=DB::table('operational_details')
->select('opening_time','closing_time')
->where('infrastructure_details_id',$inf_id)
->first();
$pricing_details=[];
$pricing_details=DB::table('pricing_details')
->where('infrastructure_details_id','=',$inf_id)
->get();
$accessory_charges=[];
$accessory_charges=DB::table('accessory_charges')
->where('infrastructure_details_id','=',$inf_id)
->get();
$discounts=[];
$discounts=DB::table('discounts')
->where('infrastructure_details_id','=',$inf_id)
->get();
$monthly_charges=[];
$monthly_charges=DB::table('monthly_court_charges')
->where('infrastructure_details_id','=',$inf_id)
->get();
if(($pricing_details->count())>0){
$request->session()->put('price_id',$pricing_details[0]->id);
}
return view('pricing_details',['inf_id'=>$inf_id,'op_id'=>$op_id,'timings'=>$timings,'pricing_details'=>$pricing_details,'acc_charges'=>$accessory_charges,'discounts'=>$discounts,'monthly_charges'=>$monthly_charges]);
}
//return view('pricing_details',['timings'=>$timings]);
//return view('home',['court_types'=>$court_types]);
}
public function create(Request $request){
$diff=$request->input('diff');
$no_accessories=$request->input('no_accessories');
$no_discounts=$request->input('no_discounts');
$no_monthly_charges=$request->input('no_monthly_charges');
for($i=0;$i<$diff;$i++){
$pricing_details=new PricingDetail;
$pricing_details->timings=$request->input('time'.$i);
$pricing_details->price=$request->input('price'.$i);
$pricing_details->discount=$request->input('discount'.$i);
$pricing_details->discounted_price=$request->input('discounted_price'.$i);
$pricing_details->disc_from_date=$request->input('disc_from_date'.$i);
$pricing_details->disc_to_date=$request->input('disc_to_date'.$i);
$pricing_details->infrastructure_details_id=$request->input('inf_id');
$pricing_details->operational_details_id=$request->input('op_id');
$pricing_details->day_types_id=$request->input('day_type'.$i);
$pricing_details->save();
}
for($i=1;$i<=$no_accessories;$i++){
$accessory_charge=new AccessoryCharge;
$accessory_charge->item=ucfirst($request->input('item'.$i));
$accessory_charge->brand=ucfirst($request->input('brand'.$i));
$accessory_charge->price=$request->input('acc_price'.$i);
$accessory_charge->quantity=$request->input('quantity'.$i);
$accessory_charge->return_type=$request->input('return_type'.$i);
$accessory_charge->infrastructure_details_id=$request->input('inf_id');
$accessory_charge->operational_details_id=$request->input('op_id');
$accessory_charge->save();
}
for($i=1;$i<=$no_monthly_charges;$i++){
$monthly_charge=new MonthlyCourtCharge;
$monthly_charge->infrastructure_details_id=$request->input('inf_id');
$no_days=0;
$scheme_type=$request->input('scheme_type'.$i);
if($scheme_type=="scheme1"){
$no_days=22;
}else{
$no_days=31;
}
$monthly_charge->scheme_type=$scheme_type;
$monthly_charge->no_days=$no_days;
$monthly_charge->hour_type=$request->input('hour_type'.$i);
$monthly_charge->from_time=date('H:i',strtotime($request->input('from_time'.$i)));
$monthly_charge->to_time=date('H:i',strtotime($request->input('to_time'.$i)));
$monthly_charge->price=$request->input('price'.$i);
$monthly_charge->save();
}
$id=$pricing_details->id;
$request->session()->put('price_id', $id);
return redirect('/facility_details');
}
public function update(Request $request){
$diff=$request->input('diff');
$no_accessories=$request->input('no_accessories');
//$no_discounts=$request->input('no_discounts');
$no_monthly_charges=$request->input('no_monthly_charges');
for($i=0;$i<$diff;$i++){
$pr_id=$request->input('pricing_id'.$i);
$pricing_details=PricingDetail::find($pr_id);
$pricing_details->timings=$request->input('time'.$i);
$pricing_details->price=$request->input('price'.$i);
$pricing_details->discount=$request->input('discount'.$i);
$pricing_details->discounted_price=$request->input('discounted_price'.$i);
$pricing_details->disc_from_date=$request->input('disc_from_date'.$i);
$pricing_details->disc_to_date=$request->input('disc_to_date'.$i);
$pricing_details->infrastructure_details_id=$request->input('inf_id');
$pricing_details->operational_details_id=$request->input('op_id');
$pricing_details->day_types_id=$request->input('day_type'.$i);
$pricing_details->save();
}
for($i=1;$i<=$no_accessories;$i++){
$acc_id=$request->input('acc_id'.$i);
$accessory_charge=AccessoryCharge::find($acc_id);
$accessory_charge->item=ucfirst($request->input('item'.$i));
$accessory_charge->brand=ucfirst($request->input('brand'.$i));
$accessory_charge->price=$request->input('acc_price'.$i);
$accessory_charge->quantity=$request->input('quantity'.$i);
$accessory_charge->return_type=$request->input('return_type'.$i);
$accessory_charge->infrastructure_details_id=$request->input('inf_id');
$accessory_charge->operational_details_id=$request->input('op_id');
$accessory_charge->save();
}
for($i=1;$i<=$no_monthly_charges;$i++){
$monthly_id=$request->input('monthly_id'.$i);
$monthly_charge=MonthlyCourtCharge::find($monthly_id);
//$monthly_charge->infrastructure_details_id=$request->input('inf_id');
$no_days=0;
$scheme_type=$request->input('scheme_type'.$i);
if($scheme_type=="scheme1"){
$no_days=22;
}else{
$no_days=31;
}
$monthly_charge->scheme_type=$scheme_type;
$monthly_charge->no_days=$no_days;
$monthly_charge->hour_type=$request->input('hour_type'.$i);
$monthly_charge->from_time=date('H:i',strtotime($request->input('from_time'.$i)));
$monthly_charge->to_time=date('H:i',strtotime($request->input('to_time'.$i)));
$monthly_charge->price=$request->input('price'.$i);
$monthly_charge->save();
}
$id=$pricing_details->id;
$request->session()->put('price_id', $id);
return redirect('/facility_details');
}
}
here is the layout code
<div class="dynamic_row2">
<div class="row">
<div class="col-md-12 bg-info text-white">
<h4 calss="h4-responsive">4. Monthly Charges</h4>
</div>
</div>
<div class="row">
<div class="col-md-2">
<h4 class="h4-responsive">Scheme Type</h4>
</div>
<div class="col-md-2">
<h4 class="h4-responsive">Hour Type</h4>
</div>
<div class="col-md-3">
<h4 class="h4-responsive">From Time</h4>
</div>
<div class="col-md-3">
<h4 class="h4-responsive">To Time</h4>
</div>
<div class="col-md-2">
<h4 class="h4-responsive">Price / hour</h4>
</div>
</div>
#php
$i=1;
#endphp
#foreach($monthly_charges as $monthly)
{{Form::hidden('monthly_id'.$i,$monthly->id)}}
<div class="row" id="discount_row1">
<div class="col-md-2">
<div class="form-group">
<select name="scheme_type<?php echo $i; ?>" class="form-control" required>
<option value="<?php echo $monthly->scheme_type; ?>" selected><?php echo $monthly->scheme_type; ?></option>
<option value="" disabled>Select Scheme</option>
<option value="scheme1">Scheme1 - 22 days</option>
<option value="scheme2">Scheme2 - 30/31 days</option>
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<select name="hour_type<?php echo $i; ?>" class="form-control" required>
<option value="<?php echo $monthly->hour_type; ?>" selected><?php echo $monthly->hour_type; ?></option>
<option value="" disabled>Select hour type</option>
<option value="Peak hour">Peak hour</option>
<option value="NonPeak hour">NonPeak hour</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{{ Form::time('from_time'.$i,$monthly->from_time,['class'=>'form-control','placeholder'=>'From Time','required']) }}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{{ Form::time('to_time'.$i,$monthly->to_time,['class'=>'form-control','placeholder'=>'From Time','required']) }}
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::number('price'.$i++,$monthly->price,['class'=>'form-control','placeholder'=>'From Time','required']) }}
</div>
</div>
</div>
#endforeach
</div>
{{Form::submit('Update',['class'=>'btn btn-primary'])}}
{!! Form::close() !!}
#endif
i have checked database datatypes since i works most of the time no problem there. i don't what iam missing

Related

Creating a dependent drop down using laravel livewire

I am trying to use laravel livewire to create a dynamic dependent drop down list.
So I have created a livewire component named assignment.
assignment.blade.php
<div>
<div class="row mb-4">
<label for="category" class="col-md-4 col-form-label text-md-end">Category</label>
<div class="col-md-6">
<select name="category" id="category" class="form-select col-md-6">
<option value="null">Select category</option>
#foreach ($categories as $item)
<option value="{{$item->id}}">{{$item->name}}</option>
#endforeach
</select>
</div>
</div>
<div class="row pt-4">
<button class="btn btn-warning text-white" wire:loading.attr="disable">Add New Product</button>
<div wire:loading>
Hold on...
</div>
</div>
</div>
assignment.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Category;
class Assignment extends Component
{
public function render()
{
return view('livewire.assignment', [
'Category' => Category::all()
]);
}
}
The livewire component is embedded on the create.blade.php. Here is a snippet
</div>
<livewire:assignment />
<div class="row mb-4">
<label for="subcategory" class="col-md-4 col-form-label text-md-end">Sub Category</label>
<div class="col-md-6">
<select name="subcategory" id="subcategory" class="form-select col-md-6">
<option value="null">Select subcategory</option>
<option value="wine">Wine</option>
<option value="whisky">Whisky</option>
Here is my productscontroller function that renders the view
public function create()
{
return view('products.create');
}
routes
Route::get('/explore', [App\Http\Controllers\ConnectsController::class, 'index']);
Route::get('/p/create', [App\Http\Controllers\ProductsController::class, 'create']);
Route::post('/p', [App\Http\Controllers\ProductsController::class, 'store']);
I am getting the following error: syntax error, unexpected end of file.
What could be the issue?
There is a typo in assignment.blade.php. #enforeach should be #endforeach. I had to post this as answer as could not post this as comment.

How to redirect to the page which shows only the data inserted to the database from that id

For example if there is a form which creates customers, and when you filled the form and submit the page should redirect and show the data which was inserted to that form by a specific individual id. in my case it redirects to a page and views all the data in the database.
Here's my Web.php
Route::get('customers','CustomersController#index');
Route::get('customers/create','CustomersController#create');
Route::post('customers','CustomersController#store');
Route::get('customers/{customer}','CustomersController#show');
Here's my Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Customer;
use App\Company;
class CustomersController extends Controller
{
public function index(){
$customers = Customer::all();
return view('customers.index',compact('customers'));
}
public function create(){
$companies = Company::all();
return view ('customers.create',compact('companies'));
}
public function store()
{
$data = request()->validate([
'name'=>'required | min:3',
'email'=>'required | email',
'active'=>'required ',
'company_id'=>'required',
]);
Customer::create($data);
return redirect('customers');
}
// * Route Model binding
public function show(Customer $customer){
return view('customers.show',compact('customer'));
}
}
Here's my Customer Model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
protected $guarded = [];
public function getActiveAttribute($attribute){
return [
0 => 'Inactive',
1 => 'Active',
] [$attribute];
}
public function scopeActive($query){
return $query->where('active',1);
}
public function scopeInactive($query){
return $query->where('active',0);
}
public function company()
{
return $this->belongsTo(Company::class);
}
}
Here's my Create Blade
#extends('layouts')
#section('title','Add New Customer')
#section('content')
<div class="row">
<div class="col-12">
<h1>Add New Customer</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="/customers" method="POST" >
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="name" value="{{old('name')}}">
<div>{{$errors->first('name')}}</div>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" name="email" value="{{old('email')}}">
<div>{{$errors->first('email')}}</div>
</div>
<div class="form-group">
<label for="">Customer Status</label>
<select name="active" id="active" class=" form-control">
<option value="" disabled>Select Customer Status</option>
<option value="1">Active</option>
<option value="0">Inactive</option>
</select>
</div>
<div class="form-group">
<label for="company_id">Company</label>
<select name="company_id" id="company_id" class=" form-control">
#foreach ($companies as $company)
<option value="{{ $company->id }}">{{ $company->name }}</option>
#endforeach
</select>
</div>
<button type="submit" class=" btn btn-dark">Add Customer</button>
#csrf
</form>
</div>
</div>
#endsection
Here's my show blade
#extends('layouts')
#section('title','Details for ' . $customer->name)
#section('content')
<div class="row">
<div class="col-12">
<h1>Details for {{ $customer->name }}</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<p><strong>Name : </strong> {{ $customer->name }}</p>
<p><strong>Email : </strong> {{ $customer->email }}</p>
<p><strong>Company : </strong> {{ $customer->company->name }}</p>
<p><strong>Status : </strong> {{ $customer->active }}</p>
</div>
</div>
#endsection
Redirect to the show route rather than the customers index route:
$customer = Customer::create($data);
return redirect('customers/' . $customer->id);

Where clause with multiple values in Laravel 5.7

I'm trying to make a report for the bus transport system, the report's form has "Driver" and "Route" fields. It works fine when I select "Driver" to get a report or select only "Route" to get the report, but there is something wrong when I choose both "Driver and Route." Any assistance would be appreciated
View/Form
<form action="" method="get">
<div class="row">
<div class="col-md-3 form-group">
<label>From Date:</label>
<input type="date" name="start" class="form-control">
</div>
<div class="col-md-3 form-group">
<label>To Date:</label>
<input type="date" name="end" class="form-control">
</div>
</div>
<div class="row">
<div class="col-md-3" id="route_content">
<label>Route</label>
<select name="routeid" id="route_id" class="js-example-placeholder-singleuserid js-states form-control"
style="width: 100%; height:40px;">
<option></option>
<?php foreach ($routes as $key => $value): ?>
<option value="{{$value->id}}">{{$value->from}} -> {{$value->to}}</option>
<?php endforeach ?>
</select>
</div>
<div class="col-md-3" id="driver_content" z>
<label>Driver</label>
<select name="driverid" id="driver_id" class="js-example-placeholder-single js-states form-control"
style="width: 100%; height:40px;">
<option></option>
<?php foreach ($driver as $key => $value): ?>
<option value="{{$value->id}}"> {{$value->name}} </option>
<?php endforeach ?>
</select>
</div>
</div>
<div class="row">
<div class="col-md-3 form-group">
<button class="btn btn-info btn-md" style="margin-top: 27px;">Search</button>
</div>
</div>
</form>
Route
Route::get('post_genral_report/{start?}/{end?}' ,
'reportController#post_genral_report')->name('abd');
Controller
public function post_genral_report(Request $request, $start = null, $end = null)
{
$data = DB::table('registration_tickets')
->join('trips', 'trips.id', 'registration_tickets.trip_id')
->join('buses', 'buses.id', 'trips.bus_id')
->join('drivers', 'drivers.id', 'trips.driver_id')
->join('routes', 'routes.id', 'trips.route_id')
->join('provinces as p1', 'p1.id', 'routes.from')
->join('provinces as p2', 'p2.id', 'routes.to')
->select('registration_tickets.*', 'p1.name as from', 'p2.name as to', 'buses.type', 'buses.plate',
'drivers.name as d_name', 'drivers.lastname as lname');
if ($start and $end) {
$data->whereBetween('registration_tickets.date', [
$start,
$end
]);
}
if ($request->driverid) {
$data->where('trips.driver_id', $request->driverid);
}
if ($request->routeid) {
$data->where('trips.route_id', $request->routeid);
}
if ($request->driverid and $request->routeid) {
$data->where([
'trips.driver_id', '=', $request->driverid,
'trips.route_id', '=', $request->routeid
]);
}
$data = $data->get();
return Datatables::of($data)->make(true);
}
You need to modify the part where you are using both driver_id and route_id to below to achieve your purpose (because as per your code, it seems that you want the results when both of route_id or driver_id falls between the start and end date, however your code checks the driver_id and route_id individually for where condition. You need to wrap them in a where and use nested where in it):
if ($request->driverid and $request->routeid) {
$data->where(function($q) use ($request)
{
$q->where('trips.driver_id', '=', $request->driverid)
->where('trips.route_id', '=', $request->routeid);
});
}

How Can I Get Admin Id and Use it across the application?

In codeigniter I want to add the product on admin Id which is required in DB Table. when Admin log in his ID must be catch. whenever and where Id is needed it must be available.
here is my VIEW in which
<?php echo form_open_multipart('admin/add_product');?>
<!------------------Product Name------------------------>
<div class="row form-group">
<div class="col-sm-10">
<label>Product Name: *</label>
<?php echo form_input(['name'=>'name','class'=>'form-
control','placeholder'=>'Product name..','value'=>
set_value('name')])?>
<div>
<?php echo form_error('name');?>
</div>
</div></div>
<!------------------Product Cat---------------------------->
<div class="row form-group">
<div class="col-sm-12">
<label>Category: *</label> <br>
<select class="selectpicker" name="pro_cat_id">
<option label="Select Category">Category</option>
<?php
foreach($product_cat as $cat)
{?>
<option value="<?= $cat['pro_cat_id'] ?>"><?= $cat['category'] ?>
</option>
<?php }?>
</select>
<div>
<!------------------Product Price---------------------------->
<div class="row form-group">
<div class="col-md-10">
<label>Product Price: *</label>
<?php echo form_input(['name'=>'price','class'=>'form-
control','placeholder'=>'Product Price..','value'=>
set_value('price')])?>
<div>
<?php echo form_error('price');?>
</div>
</div></div>
<!------------------Product Location---------------------------->
<div class="row form-group">
<div class="col-md-10">
<label>Product Location: *</label>
<?php //echo form_input(['name'=>'location','class'=>'form-
control','placeholder'=>'Product Location'])?>
</div></div>
</div></div>
<!-----------End of body---------------->
</div>
<div class="modal-footer">
<input name="" type="submit" value="ADD" class="btn btn-success">
</div>
<?php echo form_close();?>
</div>
</div>
</div>
Here is my Controller
function add_product(){
$data['product_size'] = $this->show->show_product_size();
$data['product_cat']= $this->show->show_product_category();
$data['product_color'] = $this->show->show_product_color();
$data['pr']= $this->show->show_provider();
$post= $this->input->post();
$ =this->form_validation->set_error_delimiters("<p class='text-danger'>","
</p>");
if($this->form_validation->run('add_product')){
if($this->add->add_product($post)==TRUE){
$this->db->close();
$this->session->set_flashdata('success','Product has been added
successfully');
return redirect('admins/pages/add_product_page');
//$this->load->admin_template('admin/add_product',$data);
}
}
else
{
$this->session->set_flashdata('failled','Sorry, fail to add product');
//return redirect('admins/pages/add_product_page');
$upload_error= $this->upload->display_errors();
$this->load->admin_template('admin/add_product',$data);
}
}
Use this query, preferably in your controller:
$this->session->userdata('id');

Select Option in foreach only get value in last select option (Code Igniter)

Why I can't post a select option value in foreach loop? It just save the last select option value.
It's only save the "Rutinitas" value in Printer (which is the last select option), but doesn't save the CPU or Mouse "Rutinitas" option value.
This is the controller
public function tampilkanKomponen2($tgl_cek,$nama_alat) {
if($this->session->userdata('logged_operator')) {
$session_data = $this->session->userdata('logged_operator');
$nip = $session_data['nip'];
$nama = $session_data['username'];
$hasil = $this->operator_model->getByAlat($nama_alat)->result();
$hasil2 = $this->operator_model->showPengecekan()->result();
$data =array (
'nip' => $nip,
'nama' => $nama,
'hasil2' => $hasil2,
'hasil' => $hasil,
//'hasil2' => $hasil2,
'tgl_cek' => $tgl_cek,
'nama_alat' => $nama_alat
//'id_komponen2' =>$id_komponen
);
$this->load->view('tambah_pengecekan3_v',$data);
}
else {
echo "<script> history.go(-1); </script>";
}
}
public function simpanPengecekan() {
if($this->operator_model->check_logged()==TRUE) {
$session_data = $this->session->userdata('logged_operator');
$nip = $session_data['nip'];
$id_komponen = $this->input->post('id_komponen');
$tgl_cek = $this->input->post('tgl_cek');
$rutinitas = $this->input->post('rutinitas');
$kriteria = $this->input->post('kriteria');
$tindakan = $this->input->post('tindakan');
$nama_alat = $this->input->post('nama_alat');
$data =array (
'id_komponen' => $id_komponen,
'tgl_cek' => $tgl_cek,
'rutinitas' => $rutinitas,
'kriteria' => $kriteria,
'tindakan' => $tindakan,
'operator' => $nip
);
$hasil = $this->operator_model->tambahPengecekan($data);
//redirect(base_url('operator'));
$this->tampilkanKomponen2($tgl_cek,$nama_alat);
//redirect_back();
}
else {
echo "<script> history.go(-1); </script>";
}
}
This is the view
<div class="container">
<h4> Buat Pengecekan Baru </h4>
<form method="post" action="simpanPengecekan">
<div style="border-bottom : solid black 1px;margin-bottom:30px;">
<div class="row row-form">
<div class="col-md-2"> <label class="control-label"> Tanggal Pengecekan </label> </div>
<div class="col-md-10"><input type="text" name="tgl_cek" class="form-control datepicker" value="<?php echo $tgl_cek; ?>"></div>
</div>
<div class="row row-form">
<div class="col-md-2"> <label class="control-label">Nama Alat</label> </div>
<div class="col-md-10">
<input type="text" name="nama_alat" class="form-control" value="<?php echo $nama_alat; ?>" readonly>
</div>
</div>
<button type="button" class="btn btn-primary"> Pilih Alat </button>
</div>
<h6>Komponen</h6>
<?php $no=0;foreach($hasil as $row) { ?>
<div>
<input type="hidden" name="id_komponen" id="id<?php echo +$no;?>" class="form-control" value="<?php echo $row->id_komponen;?>" disabled>
<p> <?php echo $row->nama_komponen;?> </p>
<button type="button" class="btn btn-primary" onClick="javascript:showhide('pengecekan','<?php echo +$no;?>')"> Isi Pemeriksaan </button>
<div id="pengecekan<?php echo +$no;?>" style="display:none;">
<div class="row row-form">
<div class="col-md-2"> <label class="control-label"> Rutinitas </label> </div>
<div class="col-md-10">
<select name="rutinitas" class="form-control">
<option value="Harian"> Harian </option>
<option value="Mingguan"> Mingguan </option>
<option value="Bulanan"> Bulanan </option>
<option value="3 Bulanan"> 3 Bulanan </option>
<option value="6 Bulanan"> 6 Bulanan </option>
<option value="Tahunan"> Tahunan </option>
</select>
</div>
</div>
<div class="row row-form">
<div class="col-md-2"> <label class="control-label"> Kriteria </label> </div>
<div class="col-md-10"><input type="text" class="form-control" name="kriteria"></div>
</div>
<div class="row row-form">
<div class="col-md-2"> <label class="control-label"> Tindakan </label> </div>
<div class="col-md-10"><input type="text" class="form-control" name="tindakan"></div>
</div>
<input type="submit" class="btn btn-primary" value="Simpan"> <br><br><br>
</div>
</div>
<?php $no++; } ?>
</form>
<br><button type="button" class="btn btn-wide btn-primary btn-batal">Selesai</button> <br> <br>
<button type="button" class="btn btn-wide btn-default btn-batal">Batal</button>
</div>
This is the model
THis is the result in database
Change select name to rutinitas[]
<select name="rutinitas[]" class="form-control">
<option value="Harian"> Harian </option>
<option value="Mingguan"> Mingguan </option>
<option value="Bulanan"> Bulanan </option>
<option value="3 Bulanan"> 3 Bulanan </option>
<option value="6 Bulanan"> 6 Bulanan </option>
<option value="Tahunan"> Tahunan </option>
</select>
if you want to insert all selected value in same column of table then use implode
$rutinitas = implode(',',$this->input->post('rutinitas'));

Categories