Call to a member function isvalid() on null in laravel5 - laravel-5

When Update an image, it shows follwing error. I cannot update this laravel5 form. can any one find what is my mistake?
FatalErrorException in SiteadminController.php line 308:
Call to a member function isvalid() on null
My file are
Controller
public function siteadmin_update_product(Request $request)
{
$post = $request->all();
$cid=$post['product_id'];
$product_title = $request->input('product_title');
$product_price = $request->input('product_price');
$product_discount_price = $request->input('product_discount_price');
$product_qty = $request->input('product_qty');
$deal_description = $request->input('deal_description');
$select_merchant = $request->input('select_merchant');
$select_shop = $request->input('select_shop');
$product_meta_keyword = $request->input('product_meta_keyword');
$product_meta_description = $request->input('product_meta_description');
$spec_type = $request->input('spec_type');
$specification = $request->input('specification');
$product_size = $request->input('product_size');
$product_image=Input::file('product_image');
$v =validator::make($request->all(),
[
]
);
if($v->fails())
{
return redirect()->back()->withErrors($v->errors());
}
else
{
if($product_image->isvalid())
{
$extension=$product_image->getClientOriginalName();
$move_img = explode('.',$extension);
$fileName=$move_img[0].str_random(8).".".$move_img[1];
$destinationPath = '../assets/productimage/';
$uploadSuccess=Input::file('product_image')->move($destinationPath,$fileName);
$data = array(
'product_title' => $product_title,
'product_price' => $product_price,
'product_discount_price' => $product_discount_price,
'product_qty' => $product_qty,
'select_merchant' => $select_merchant,
'select_shop' => $select_shop,
'product_meta_keyword' => $product_meta_keyword,
'product_meta_description' => $product_meta_description,
'spec_type' => $spec_type,
'specification' => $specification,
'product_size' => $product_size,
'product_image'=> $fileName,
);
$ch=Product_model::update_product($data,$cid);
//$ch=DB::table('le_banner')->where('banner_id',$post['id'])->update($data);
if($ch > 0)
{
Session::flash ('message_update', 'Record Updated Successfully');
return redirect('siteadmin_manageproduct');
}
else
{
return Redirect('siteadmin_editproduct');
}
}
}
}
Model
public static function update_product($data,$cid)
{
return DB::table('le_product')->where('product_id',$cid)->update($data);
}
View:
<form class="form-horizontal form-label-left" enctype="multipart/form-data" novalidate action="{{action('SiteadminController#siteadmin_update_product')}}" method="POST">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<input type="hidden" class="form-control" name="product_id" value="<?php echo $row->product_id ?>" id="id">
<!-- text input -->
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Product Title*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="3" name="product_title" placeholder="Product Title" required="required" type="text" value="<?php echo $row->product_title ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="heard">Select Main Category<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="heard" class="form-control" required>
<option value="press">option 1</option>
<option value="net">option 2</option>
<option value="mouth">option 3</option>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="heard">Select Sub Category<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="heard" class="form-control" required>
<option value="press">option 1</option>
<option value="net">option 2</option>
<option value="mouth">option 3</option>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="heard">Select Second Sub Category<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="heard" class="form-control" required>
<option value="press">option 1</option>
<option value="net">option 2</option>
<option value="mouth">option 3</option>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Product Quantity*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="1" name="product_qty" placeholder="Product Quantity" required="required" type="number" value="<?php echo $row->product_qty ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Original Price*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="number" class="form-control col-md-7 col-xs-12" data-validate-length-range="2" name="product_price" placeholder="Original Price" required="required" type="number" value="<?php echo $row->product_price ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Discounted Price*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="number" class="form-control col-md-7 col-xs-12" data-validate-length-range="2" name="product_discount_price" placeholder="Discounted Price" required="required" type="number" value="<?php echo $row->product_discount_price ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-3 col-xs-10"></label>
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="chkPassport">
<input type="checkbox" id="chkSelect" checked/> ( Including tax amount )
</label>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-10"></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="number" id="txtUsername" class="form-control col-md-7 col-xs-12" name="product_incometax" placeholder="Tax Amound" value="<?php echo $row->product_incometax ?>" />
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Shipping Amount*</label>
<label class="control-label col-md-2 col-sm-3 col-xs-12" for="chkNo">
<input type="radio" id="chkNo" name="chkPassPort" checked/>
Free
</label>
<label class="control-label col-md-2 col-sm-3 col-xs-12" for="chkYes">
<input type="radio" id="chkYes" name="chkPassPort" />
Amount
</label>
</div>
<div class="item form-group" id="dvPassport1" style="display: none">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Shipping Amount*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="number" id="txtPassportNumber" class="form-control col-md-7 col-xs-12" value="<?php echo $row->product_shippement_amount ?>" name="product_shippement_amount"/>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Description <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="textarea" required="required" name="product_description" class="form-control col-md-7 col-xs-12" placeholder="Description" data-validate-length-range="20"><?php echo $row->product_description ?></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Want to add specification*</label>
<label class="control-label col-md-2 col-sm-3 col-xs-12" for="Yes">
<input type="radio" id="Yes" name="r4" />
Yes
</label>
<label class="control-label col-md-2 col-sm-3 col-xs-12" for="No">
<input type="radio" id="No" name="r4" checked/>
No
</label>
</div>
<div class="item form-group" id="dvPassport2" style="display: none">
<label class="control-label col-md-3 col-sm-2 col-xs-10">Specification*</label>
<div class="col-md-4 col-sm-6 col-xs-12">
<select id="txtPassportNumber1" class="form-control" required value="<?php echo $row->spec_type?>" name="spec_type">
<?php
foreach($specification as $roww)
{?>
<option value="<?php echo $roww->spec_id;?>"><?php echo $roww->specification_name;?></option>
<?php
}
?>
</select>
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<input type="text" id="txtPassportNumber1" class="form-control col-md-7 col-xs-12" required data-validate-length-range="3" value="<?php echo $row->specification ?>" name="specification"/>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="heard">Product Size<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="heard" class="form-control" required value="<?php echo $row->product_size ?>" name="product_size">
<?php
foreach($size as $roww)
{?>
<option value="<?php echo $roww->id;?>"><?php echo $roww->size;?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="states">Product Color*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="colorselector" class="form-control">
<option value="red">Red</option>
<option value="yellow">Yellow</option>
<option value="blue">Blue</option>
</select>
</div>
</div>
<div class="item form-group">
<div class="output">
<label class="control-label col-md-3 col-sm-3 col-xs-12"></label>
<div id="red" class="colors red"> <input type="checkbox" checked/>RED </div>
<div id="yellow" class="colors yellow"> <input type="checkbox" checked/> YELLOW</div>
<div id="blue" class="colors blue"><input type="checkbox" checked/> BLUE</div>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Delivery Days*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="number" class="form-control" placeholder="Delivery Days" name="product_days" required value="4" value="<?php echo $row->product_days ?>">
Eg : (2-5)
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="heard">Select Merchant<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="heard" class="form-control" required value="<?php echo $row->select_merchant ?>" name="select_merchant">
<?php
foreach($merchant as $roww)
{?>
<option value="<?php echo $roww->merchant_id;?>" >
<?php echo $roww->merchant_firstname;?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="heard">Select Shop<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<select id="heard" class="form-control" required value="<?php echo $row->select_shop ?>"
name="select_shop">
<?php
foreach($merchant as $roww)
{?>
<option value="<?php echo $roww->store_id;?>" >
<?php echo $roww->store_name;?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Meta Keywords
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="textarea" name="product_meta_keyword" class="form-control col-md-7 col-xs-12" placeholder="Meta Keywords"><?php echo $row->product_meta_keyword ?></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Meta Description
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="textarea" name="product_meta_description" class="form-control col-md-7 col-xs-12" placeholder="Meta Description"><?php echo $row->product_meta_description ?></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Product Image </label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="file" name="product_image" value=""><br>
<img src="{{ url('../assets/productimage/').'/'.$row->product_image}}" style="height:90px;">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Product Image </label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="file" name="product_image" value=""><br>
<img src="{{ url('../assets/productimage/').'/'.$row->product_second_image}}" style="height:90px;">
</div>
</div>
<div class="item form-group">
<div class="col-md-3"></div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-success" type="submit">Update</button>
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-danger" type="reset">Cancel</button>
</div>
</div>
</form>

You have two file inputs with the name product_image. That's why your file is empty, and isValid() throws an error. You can use hasFile() to avoid exceptions like that.

replace
Input::file('image')->isValid()
to
Input::hasFile('image')

Related

How do i update the content in my database?

I am trying to update values I got from the database but it seems not to be going to the routes function
I tried changing the routes method and even die down the request but it seems not to work
Here is the route
Route::put("/users/bonus/update/{id}",
[
"uses" => "AdminDashboardController#updatebonus",
"as"=> "userbonus.mer"
]);
below is the function that is been called to update
public function updatebonus(Request $request, $id)
{
if (auth()->user()->isAdmin != 1) {
return redirect()->route('home');
} else if (auth()->user()->isAdmin == 1) {
$bonus=OtherBonus::where('id','=','$id')->first();
$bonus->card_bonus=trim(strip_tags($request['cbonus']));
$bonus->monthly_bonus=trim(strip_tags($request['mbonus']));
$bonus->travelling_bonus=trim(strip_tags($request['tbonus']));
$bonus->festival_bonus=trim(strip_tags($request['fbonus']));
$bonus->save();
return redirect()->back()->with("success", "Bonus Settings
Successfully updated");
}
}
below is the form that passes the data to the function which communicates with the database.
<form class="form-horizontal form-label-left" action="{{route('userbonus.mer', ['id'=>$bonus['id']])}}" method="PUT">
<span class="section">General Bonus in %age</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="cbonus">Card
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input class="form-control col-md-7 col-xs-12"
value="{{$bonus['card_bonus']}}" name="cbonus"
placeholder="10.00%" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="fbonus">Festival
Bonus<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="fbonus" required="required"
value="{{$bonus['festival_bonus']}}"
class="form-control col-md-7 col-xs-12" placeholder="34.6%">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="mbons">Monthly
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="mbonus" required="required"
value="{{$bonus['monthly_bonus']}}" placeholder="56.9%"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbonus">Travelling
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="tbonus" placeholder="0.89%"
value="{{$bonus['travelling_bonus']}}" required="required"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="reset" class="btn btn-primary">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
The HTML form doesn't accept PUT as method. It only works with GET and POST. Have a look here. So if you write
<form method="PUT"></form>
you're going to submit the form as a GET request. Laravel listens for a specific input that has to present after form submission in order to recognize the PUT method. Have a look at the official documentation
HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form. The value sent with the _method field will be used as the HTTP request method:
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
You may use the #method Blade directive to generate the _method input:
<form action="/foo/bar" method="POST">
#method('PUT')
#csrf
</form>
Try This
public function updatebonus(Request $request, $id)
{
if (auth()->user()->isAdmin != 1) {
return redirect()->route('home');
} else if (auth()->user()->isAdmin == 1) {
$bonus=OtherBonus::find($id);
$bonus->update([
'monthly_bonus'=>$request->mbonus,
'travelling_bonus'=>$request->tbonus,
'festival_bonus'->$request->fbonus;
]);
return redirect()->back()->with("success", "Bonus Settings
Successfully updated");
}
}
And BLADE FILE JUST CHANGE METHOD TO post & and after this add {{method_field('PUT')}}
{{csrf_field()}}
<form class="form-horizontal form-label-left" action="{{route('userbonus.mer', ['id'=>$bonus['id']])}}" method="post">
{{method_field('PUT')}}
{{csrf_field()}}
<span class="section">General Bonus in %age</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="cbonus">Card
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input class="form-control col-md-7 col-xs-12"
value="{{$bonus['card_bonus']}}" name="cbonus"
placeholder="10.00%" required="required" type="text">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="fbonus">Festival
Bonus<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="fbonus" required="required"
value="{{$bonus['festival_bonus']}}"
class="form-control col-md-7 col-xs-12" placeholder="34.6%">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="mbons">Monthly
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="mbonus" required="required"
value="{{$bonus['monthly_bonus']}}" placeholder="56.9%"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tbonus">Travelling
Bonus <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" id="email" name="tbonus" placeholder="0.89%"
value="{{$bonus['travelling_bonus']}}" required="required"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button type="reset" class="btn btn-primary">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
In Route make it post

how to fix,"Call to a member function row() on null "

How to fix
Call to a member function row() on null
THIS IS MY CONTROLLER
function forwardtrack($param='',$param2='') {
if(sizeof($this->db->get_where('st_forward',array('letter_no' =>$param.'/'.$param2))->result_array())>0 && (!($param.'/'.$param2) )){
$data1['message']= 'notallow';
$this->load->view('track1',$data1);
}
else{
$data1['name']=$this->db->get_where('bpas_user_profiles',array('AgencyMainParentID' =>$this->session->userdata('ministryId'),'AgencyParentID'=>$this->session->userdata('parentID'),'AgencyID'=>$this->session->userdata('agencyID')))->result_array();
$data1['userdeatils']=$this->ag->tracks($param.'/'.$param2);
$this->load->view('userManagement/forward2', $data1);
}
/* ag=> agency model */
}
THIS IS MY MODEL
public function tracks($letterno="")
{
$query= $this->db->get_where('st_dak_details',array('dakLetterNo'=>$letterno))->row();
return $query;
}
THIS VIEW PAGE
<br/>
<div class="container">
<div class="panel panel-info">
<div class="panel-heading">
<i class="fa fa-envelope-o fa-fw"></i>forward to
</div>
<div class="panel-body">
<form class="form-horizontal" enctype="multipart/form-data" action="#" method="post" id="forwardmessage">
<div class="form-group">
<label for="letter"class="col-xs-12 col-lg-1 col-sm-1 col-md-1">letter_no: </label>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-credit-card"></i></span>
<?php
foreach($userdeatils->row() as $row): ?>
<input name="dakLetterNo" id="dakLetterNo" value="<?php echo $row['dakLetterNo'];?>"readonly="true" class="form-control" type="text" required />
</div>
</div>
<!-- <div class="form-group">
<label class="col-xs-12 col-lg-2 col-sm-2 col-md-2">created: </label>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-credit-card"></i></span>
<input name="copy_to" id="copy_to" value="<?php //echo $userdeatils->created;?>"readonly="true" class="form-control" type="text" required />
</div> -->
<div class="form-group">
<label class="col-xs-12 col-lg-2 col-sm-2 col-md-2 control-label">Attachment: </label>
<div class="col-xs-12 col-lg-10 col-sm-10 col-md-10">
<input type="file" name="Attachment" id="Attachment">
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-lg-2 col-sm-2 col-md-2">Subject: </label>
<div class="input-group" class="col-xs-12 col-lg-10 col-sm-10 col-md-10">
<span class="input-group-addon" id="subjecterr"><i class="glyphicon glyphicon-credit-card"></i></span>
<input name="subject" id="Remark" value="<?php echo $row['Remark'];?>"readonly="true" class="form-control" type="text" required />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-lg-2 col-sm-2 col-md-2">Place: </label>
<div class="input-group" class="col-xs-12 col-lg-10 col-sm-10 col-md-10">
<span class="input-group-addon"><i class="glyphicon glyphicon-credit-card"></i></span>
<input name="place" id="place" value="<?php echo $row['place'];?>"readonly="true" class="form-control" type="text" required />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-lg-2 col-sm-2 col-md-2">from: </label>
<div class="input-group" class="col-xs-12 col-lg-10 col-sm-10 col-md-10">
<span class="input-group-addon"><i class="glyphicon glyphicon-credit-card"></i></span>
<input name="from" id="receieve_add" value="<?php echo $row['receieve_add'];?>"readonly="true" class="form-control" type="text" required />
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-lg-2 col-sm-2 col-md-2">Created: </label>
<div class="input-group" class="col-xs-12 col-lg-10 col-sm-10 col-md-10">
<span class="input-group-addon"><i class="glyphicon glyphicon-credit-card"></i></span>
<input name="created" id="created" value="<?php echo $row['created'];?>"readonly="true" class="form-control" type="text" required />
</div>
</div>
<!-- </div> -->
<!-- <div class="form-group"> -->
<!-- <label class="col-xs-12 col-lg-2 col-sm-2 col-md-2">Message: </label> -->
<!-- <div class="input-group" class="col-xs-12 col-lg-10 col-sm-10 col-md-10"> -->
<!-- <span class="input-group-addon"><i class="glyphicon glyphicon-credit-card"></i></span> -->
<!-- <input name="message" id="message" value="<?php //echo $userdeatils->created;?>"readonly="true" class="form-control" type="text" required /> -->
<!-- </div> -->
<!-- </div> -->
<?php endforeach;?>
<div class="form-group">
<label class="col-lg-2 col-xs-12 col-sm-2 col-md-2">Message: </label>
<div class="col-xs-12 col-lg-10 col-sm-10 col-md-10">
<textarea class="form-control" id="message" name="message"></textarea>
<span id="messageerr" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 col-xs-12 col-sm-2 col-md-2">
Forward to
</label>
<div class="col-lg-6 col-xs-12 col-sm-6 col-md-6">
<select name="forwardto[]" id="agency" class="form-control">
<option value="">Select</option>
<?php
foreach($name as $row): ?>
<option value="<?php echo $row['cid']?>">
<?php echo $row['FirstName'].$row['MiddleName'].$row['LastName']?>
</option>
<?php endforeach;?>
</select>
<span id="forwarderr" class="text-danger"></span>
</div>
Model:
public function tracks($letterno="")
{
$query= $this->db->get_where('st_dak_details',array('dakLetterNo'=>$letterno));
if ($query->num_rows() > 0) {
return $query->row();
} else {
return array();
}
}
Controller:
function forwardtrack($param = '', $param2 = '') {
if (sizeof($this->db->get_where('st_forward', array('letter_no' => $param . '/' . $param2))->result_array()) > 0 && (!($param . '/' . $param2) )) {
$data1['message'] = 'notallow';
$this->load->view('track1', $data1);
} else {
$data1['name'] = $this->db->get_where('bpas_user_profiles', array('AgencyMainParentID' => $this->session->userdata('ministryId'), 'AgencyParentID' => $this->session->userdata('parentID'), 'AgencyID' => $this->session->userdata('agencyID')))->result_array();
$data1['userdeatils'] = $this->ag->tracks($param . '/' . $param2);
$this->load->view('userManagement/forward2', $data1);
}
/* ag=> agency model */
}
View:
<?php
if(!empty($userdeatils)){
foreach($userdeatils as $row) { ?>
//yout html code
...
...
<?php } ?>//foreach close
<?php } ?>//if close

how to write ckeditor code in laravel form view in laravel

Hello everyone i want to add ckeditor in my view which has multiple divs. How can i do that by adding this ckeditor code:
<title>A Simple Page with CKEditor</title>
<script src="../ckeditor.js"></script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
</body>
And this is my view
#extends('sadmin.main-template')
#section('title', 'Super admin Dashboard')
#section('title', 'Add Plan')
#section('content')
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12 right-sidebar admin-client add-client">
#include('partials.errors')
<form action="{{url('sadmin/add_plan')}}" class="toggle-disabled" method="post">
{!! csrf_field() !!}
<h3 class="title">Add a plan</h3>
<div class="form-group">
<label >You Can Create Your Plan Here</label>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 left-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Name</span>
<input type="text" class="form-control" id="name" name="name" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Price</span>
<input type="text" class="form-control" id="name" name="price" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Allowed Users</span>
<input type="text" class="form-control" id="name" name="allowed_users" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Can Trail</span>
<input type="text" class="form-control" id="canTrail" name="can_trail" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="form-group">
<label class="form-label name">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 left-client-title">
<span class="form-name">Trail Duration</span>
<input type="text" class="form-control" id="password" name="trail_duration" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Detail 1</span>
<input type="text" class="form-control" id="passwordConfirmation" name="detail1" placeholder="" data-validation="custom" data-validation="required">
</label>
</div>
</div>
<div class="form-group">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<label class="form-label name">
<span class="form-name">Detail 2</span>
<input type="text" class="form-control" id="phoneNumber" name="detail2" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
<div class="form-group">
<label class="form-label name">
<span class="form-name">Staff Profiles</span>
<input type="text" class="form-control" id="planName" name="staff_profiles" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 left-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Space Management</span>
<input type="text" class="form-control" id="planPrice" name="space_management" placeholder="" data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$">
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Currency Unit</span>
<input type="text" class="form-control" id="allowedUsers" name="currency_unit" placeholder=""data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$" >
</label>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 right-client-title">
<div class="form-group">
<label class="form-label name">
<span class="form-name">Location charges</span>
<input type="text" class="form-control" id="allowedUsers" name="location_charges" placeholder=""data-validation="custom" data-validation-regexp="^([A-Za-z ]+)$" >
</label>
</div>
</div>
</div>
<p> </p>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center">
<div align="center">
<button type="submit" class="btn btn-success" style="padding-left:90px; padding-right:90px;"><strong>Submit</strong></button>
</div>
</div>
</div>
</section>
</div>
#endsection
How i can apply ckeditor code in each div any help would be appreciated.

Fields does not Update in laravel5

I am working on Laravel Form data Updation with image update. Now here my image only update smoothly in my DB. But other field does not update. anyone can identify what is my mistake? i attached my code below:
Controller
public function siteadmin_update_ads(Request $request)
{
$post = $request->all();
$cid=$post['id'];
$name = $post['ads_title'];
$url = $post['ads_url'];
$img=Input::file('ads_image');;
$v=validator::make($request->all(),
[
'ads_title'=>'required',
'ads_url' => 'required',
'ads_image'=> 'required'
]
);
if($v->fails())
{
return redirect()->back()->withErrors($v->errors());
}
else
{
if($img->isvalid())
{
$extension=$img->getClientOriginalName();
$move_img = explode('.',$extension);
$fileName=$move_img[0].str_random(8).".".$move_img[1];
$destinationPath = '../assets/adsimage/';
$uploadSuccess=Input::file('ads_image')->move($destinationPath,$fileName);
$data=array(
'ads_title'=> $name,
'ads_url'=> $url,
'ads_image'=>$fileName,
);
$i=Ads_model::update_ads($data,$cid);
if($i>0)
{
Session::flash ('message_update', 'Record Updated Successfully');
return redirect('siteadmin_manageads');
}
}
else {
return Redirect('siteadmin_editads');
}
}
}
Model
public static function update_ads($data,$cid)
{
return DB::table('le_ads')->where('id',$cid)->update($data);
}
View
<form class="form-horizontal form-label-left" id="myform" novalidate method="POST" action="{{action('SiteadminController#siteadmin_update_ads')}}" enctype="multipart/form-data">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<input type="hidden" class="form-control" name="id" value="<?php echo $row->id ?>" id="id">
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Ad Title<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form- control col-md-7 col-xs-12" data-validate-length-range="3" name="ads_title" placeholder="Ad Title" required type="text" value="<?php echo $row->ads_title ?>">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Upload Image*</label>
<div class="col-md-9 col-sm-6 col-xs-12">
<input type='file' id="field" class='demo left' name='ads_image' data-type='image' data-max-size='2mb'/><br>
<img src="{{ url('../assets/adsimage/').'/'.$row->ads_image}}" style="height:90px;">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Redirect URL<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="3" name="ads_url" placeholder="Redirect URL" required type="url" value="<?php echo $row->ads_url ?>">
</div>
</div>
<div class="item form-group">
<div class="col-md-3"></div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-success" type="submit">Update</button>
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-danger" type="reset">Cancel</button>
</div>
</div>
</form>

how to save data/records from html form to DB2 database

this is my html form
<form class="form-horizontal" id="myCredantials" >
<div class="form-group">
<label class="col-sm-2 control-label">Username : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" id="tbUsername" placeholder="Username">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Email : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" id="tbEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Gender : </label>
<div class="col-sm-10 col-md-2">
<select id="cbmGender">
<option value="-1">Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Date : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" id="tbDate">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Price : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" value="0" id="tbPrice" placeholder="Prices">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Perc % : </label>
<div class="col-sm-10 col-md-2">
<input type="text" class="form-control" value="0" id="tbPercentage" placeholder="%">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Password : </label>
<div class="col-sm-10 col-md-2">
<input type="password" class="form-control" id="tbPassword" placeholder="Password">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Confirm Password : </label>
<div class="col-sm-10 col-md-2">
<input type="password" class="form-control" id="tbConfirmpassword" placeholder="Confirm">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="button" class="btn btn-primary " id="btnSubmit" onclick="onSave()" value="Save" >
<input type="button" class="btn btn-primary " id="btnClear" onclick="onClearError()" value="Remove Error" >
<input type="button" class="btn btn-primary " id="btnGet" onclick="doGet()" value="Get" >
<input type="button" class="btn btn-primary " id="btnGet" onclick="doPost()" value="Post" >
</div>
</div>
<div style="width:700px;">
<table cellpadding="0" cellspacing="0" border="0" width="700" id="tbl_Credantials">
</table>
</div>
</form>

Resources