Skip to content

Instantly share code, notes, and snippets.

@nWidart
Created November 1, 2012 15:21
Show Gist options
  • Save nWidart/3994287 to your computer and use it in GitHub Desktop.
Save nWidart/3994287 to your computer and use it in GitHub Desktop.
public function post_edit_marker($id)
{
$input = Input::all();
$file = Input::file('img_input');
$rules = array(
'name' => 'required|max:150|alpha',
'address' => 'required|max:200|alpha_num',
'lat' => 'required|numeric',
'lng' => 'required|numeric',
'type' => 'required|alpha',
'img_input' => 'mimes:jpg,gif,png|image'
);
$v = Validator::make($input, $rules);
if ( $v->fails() )
{
return Redirect::to_action('home@edit_marker/'.$id)->with_errors($v);
}
else
{
if (array_get($file, $file['tmp_name']))
{
//Input::upload('img_input', path('public').'/img/uploads', $file['name']);
// save thumbnail,
$success = Resizer::open( $file )
->resize( 50 , 50 , 'crop')
->save( 'public/img/uploads'.$file['name'] , 90);
if ($success)
{
$marker = Marker::where('id', '=', $id)->first();
$marker->name = $input['name'];
$marker->address = $input['address'];
$marker->lat = $input['lat'];
$marker->lng = $input['lng'];
$marker->type = $input['type'];
$marker->client_id = (Session::has('client_id_s')) ? Session::get('client_id_s') : $input['client'];
$marker->rem1 = ( !empty($input['rem1']) ) ? $input['rem1'] : '';
$marker->rem2 = ( !empty($input['rem2']) ) ? $input['rem2'] : '';
$marker->rem3 = ( !empty($input['rem3']) ) ? $input['rem3'] : '';
$marker->rem4 = ( !empty($input['rem4']) ) ? $input['rem4'] : '';
$marker->rem5 = ( !empty($input['rem5']) ) ? $input['rem5'] : '';
$marker->save();
return Redirect::to_action('home@edit_marker/'.$id)->with('message', 'Marker updated!');
}
else
{
return "Image not saved.";
}
}
}
}
public function post_edit_marker($id)
{
$input = Input::all();
$file = Input::file('img_input');
$rules = array(
'name' => 'required|max:150|alpha',
'address' => 'required|max:200|alpha_num',
'lat' => 'required|numeric',
'lng' => 'required|numeric',
'type' => 'required|alpha',
'img_input' => 'mimes:jpg,gif,png|image'
);
$v = Validator::make($input, $rules);
if ( $v->fails() )
{
return Redirect::to_action('home@edit_marker/'.$id)->with_errors($v);
}
else
{
if (array_get($file, $file['tmp_name']))
{
//Input::upload('img_input', path('public').'/img/uploads', $file['name']);
// save thumbnail,
$success = Resizer::open( $file )
->resize( 50 , 50 , 'crop')
->save( 'public/img/uploads'.$file['name'] , 90);
}
$marker = Marker::where('id', '=', $id)->first();
$marker->name = $input['name'];
$marker->address = $input['address'];
$marker->lat = $input['lat'];
$marker->lng = $input['lng'];
$marker->type = $input['type'];
$marker->client_id = (Session::has('client_id_s')) ? Session::get('client_id_s') : $input['client'];
$marker->rem1 = ( !empty($input['rem1']) ) ? $input['rem1'] : '';
$marker->rem2 = ( !empty($input['rem2']) ) ? $input['rem2'] : '';
$marker->rem3 = ( !empty($input['rem3']) ) ? $input['rem3'] : '';
$marker->rem4 = ( !empty($input['rem4']) ) ? $input['rem4'] : '';
$marker->rem5 = ( !empty($input['rem5']) ) ? $input['rem5'] : '';
$marker->save();
return Redirect::to_action('home@edit_marker/'.$id)->with('message', 'Marker updated!');
}
}
echo Form::control_group(Form::label('img_input', 'Image'),
Form::file('img_input'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment