Category Archives: Laravel
laravel relationships one to one example
Laravel Date Field
{{ HTML::script(‘//code.jquery.com/jquery-1.10.2.js’); }}
{{ HTML::script(‘//code.jquery.com/ui/1.11.0/jquery-ui.js’); }}
{{ HTML::style(‘//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css’); }}
{{ HTML::style(‘//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css’); }}
{{ HTML::script(‘//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js’); }}
</head>
// STORE (controller)
$date_payment = Input::get(‘date_payment’); // Get the field
$date_payment_to_date = date(“Y-m-d”, strtotime($date_payment)); // μετατροπή
$date_expiry = Input::get(‘date_expiry’); // Get the field
$date_expiry_to_date = date(“Y-m-d”, strtotime($date_expiry)); // μετατροπή
$offer = new Offer;
$offer->title = Input::get(‘title’);
$offer->description = Input::get(‘description’);
$offer->date_payment = $date_payment_to_date;
$offer->date_expiry = $date_expiry_to_date;
$offer->save();
// VIEW
<div class=”form-group”>
{{ Form::label(‘date_payment’, ‘Date payment’) }}
{{ Form::text(‘date_payment’, Input::old(‘date_payment’), array(‘id’ => ‘datepicker’)) }}
</div>
<div class=”form-group”>
{{ Form::label(‘date_payment’, ‘Date payment’) }}
{{ Form::text(‘date_payment’, Input::old(‘date_payment’), array(‘id’ => ‘datepicker2’)) }}
</div>
<script>
$(function() {
var date = $(‘#datepicker’).datepicker({ dateFormat: ‘dd-mm-yy’ }).val();
var date = $(‘#datepicker2’).datepicker({ dateFormat: ‘dd-mm-yy’ }).val();
});
</script>