How to show data after user click an option from drop down list? - laravel

I want to show the data after user have selected the project.
I've tried several method but none of them can show the next data.
I want to create as simple as when user choose a project, it'll show the next question such as select product, select period, etc.
this is my form.blade.php
#extends('layouts.master')
#section('style')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheer" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style type="text/css">
.box{
width:600px;
margin:0 auto;
border:1[x solid #ccc;]
}
</style>
#endsection
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Add Prospect</div>
<form action="{{ url('/add/outlet') }}" method="post" enctype="multipart/form-data">
#csrf
<div class="card-body">
<div class="form-group">
<select name="project_name" id="project" class="form-control input-lg dynamic" data-dependent="product">
<option value="">Select Project</option>
#foreach($project_list as $project)
<option value="{{$project->project}}"> {{$project->project}} </option>
#endforeach
</select>
</div>
<div class="form-group">
<select name="product_name" id="product" class="form-control input-lg">
<option value="">Select Product</option>
<option value="HelloBill Retail">HelloBill Retail</option>
<option value="HelloBill FNB">HelloBill FNB</option>
</select>
</div>
<div class="form-group">
<select name="period" id="period" class="form-control input-lg">
<option value="">Select Period</option>
<option value="Bulanan">Bulanan</option>
<option value="Tahunan">Tahunan</option>
</select>
</div>
<div class="form-group row">
<label for="outlet" class="col-md-4 col-form-label text-md-left">Outlet</label>
<div class="col-md-8">
<input id="outlet" type="text" class="form-control{{ $errors->has('outlet') ? ' is-invalid' : '' }}" name="outlet" value="{{ old('outlet') }}" required autofocus>
#if ($errors->has('outlet'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('outlet') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="alamat" class="col-md-4 col-form-label text-md-left">Alamat</label>
<div class="col-md-8">
<input id="addressLine1" type="text" class="form-control{{ $errors->has('addressLine1') ? ' is-invalid' : '' }}" name="addressLine1" value="{{ old('addressLine1') }}" placeholder="Address Line #1" required autofocus>
#if ($errors->has('addressLine1'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('addressLine1') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-left"></label>
<div class="col-md-8">
<input id="addressLine2" type="text" class="form-control" name="addressLine2" value="{{ old('addressLine2') }}" placeholder="Address Line #2" required autofocus>
</div>
</div>
<div class="form-group row">
<label for="kelurahan" class="col-md-4 col-form-label text-md-left"></label>
<div class="col-md-8">
<input id="kelurahan" type="text" class="form-control{{ $errors->has('kelurahan') ? ' is-invalid' : '' }}" name="kelurahan" value="{{ old('kelurahan') }}" placeholder="Kelurahan" required autofocus>
#if ($errors->has('kelurahan'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('kelurahan') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="kecamatan" class="col-md-4 col-form-label text-md-left"></label>
<div class="col-md-8">
<input id="kecamatan" type="text" class="form-control{{ $errors->has('kecamatan') ? ' is-invalid' : '' }}" name="kecamatan" value="{{ old('kecamatan') }}" placeholder="Kecamatan" required autofocus>
#if ($errors->has('kecamatan'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('kecamatan') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="kota" class="col-md-4 col-form-label text-md-left"></label>
<div class="col-md-8">
<input id="kota" type="text" class="form-control{{ $errors->has('kota') ? ' is-invalid' : '' }}" name="kota" value="{{ old('kota') }}" placeholder="Kota" required autofocus>
#if ($errors->has('kota'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('kota') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="provinsi" class="col-md-4 col-form-label text-md-left"></label>
<div class="col-md-8">
<input id="provinsi" type="text" class="form-control{{ $errors->has('provinsi') ? ' is-invalid' : '' }}" name="provinsi" value="{{ old('provinsi') }}" placeholder="Provinsi" required autofocus>
#if ($errors->has('provinsi'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('provinsi') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="zipCode" class="col-md-4 col-form-label text-md-left"></label>
<div class="col-md-8">
<input id="zipCode" type="text" class="form-control{{ $errors->has('zipCode') ? ' is-invalid' : '' }}" name="zipCode" value="{{ old('zipCode') }}" placeholder="Kode Pos" required autofocus>
#if ($errors->has('zipCode'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('zipCode') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="PIC" class="col-md-4 col-form-label text-md-left">PIC</label>
<div class="col-md-8">
<input id="PIC" type="text" class="form-control{{ $errors->has('PIC') ? ' is-invalid' : '' }}" name="PIC" value="{{ old('PIC') }}" required autofocus>
#if ($errors->has('PIC'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('PIC') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-left">Email</label>
<div class="col-md-8">
<input id="email" type="text" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>
#if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
Add
</button>
</div>
</div>
#if($errors->any())
<div class="category-msg-error">{{ $errors->first() }}</div>
#endif
</div>
</form>
</div>
</div>
</div>
</div>
#endsection
#section('extra')
<script>
$(document).ready(function(){
$('.dynamic').change(function(){
if($(this).val()!=''){
var select = $(this).attr("id");
var value = $(this).val();
var dependent = $(this).data('dependent');
var __token = $('input[name=_token"]').val();
$.ajax({
url:"{{route('dynamicdependent.fetch')}}",
method:"POST",
data:{select:select, value:value, _token:_token,
dependent=dependent},
success:function(result){
$('#+dependent').html(result);
}
})
}
});
});
</script>
#endsection
please help. and i am also new in Laravel

There are two mistakes:-
In ajax request data you are setting dependent=dependent that should be dependent: dependent.
In Success response, you are setting this $('#+dependent').html(result); but that is not correct. It should be this $('#'+dependent).html(result);
Below is the full jQuery code:
<script>
$(document).ready(function(){
$('.dynamic').change(function(){
if($(this).val()!=''){
var select = $(this).attr("id");
var value = $(this).val();
var dependent = $(this).data('dependent');
var __token = $('input[name=_token"]').val();
$.ajax({
url:"{{route('dynamicdependent.fetch')}}",
method:"POST",
data:{
select:select,
value:value,
_token:_token,
dependent:dependent
},
success:function(result){
$('#'+dependent).html(result);
}
});
}
});
});
</script>
Please check and let me know if that will not help. I will try to solve your problem.

Related

syntax error, unexpected 'layouts' (T_STRING), expecting ')' (View: C:\xampp7\htdocs\shopping\resources\views\auth\register.blade.php)

ican not open to page "register.blade.php" when I click to register itt alert this error
syntax error, unexpected 'layouts' (T_STRING), expecting ')' (View: C:\xampp7\htdocs\shopping\resources\views\auth\register.blade.php) I can open page login.blade.php
my code in app.blade.php::
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
#if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#endif
There is a problem with your Register helper function, you are missing ')
<button type="submit" class="btn btn-primary">
{{ __('Register}}
</button>
Change to
<button type="submit" class="btn btn-primary">
{{ __('Register')}}
</button>
register.blade.php::
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
#csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
#error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="new-password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register}}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection

How to solve Missing required parameters for [Route: update_pns] [URI: update/{id}]

I want to create Update fucntion . i create the form , i displaying dataon this form , i create button submit to submit this data . but after i submit i get error
Missing required parameters for [Route: update_pns] [URI: update/{id}].
its my Controller to showing data
public function edit_pns($id)
{
$pns = Data_pns::findOrFail($id);
if (!$pns)
abort(404);
$agama = DB::table('master_agama')->pluck('agama','id');
$golongan = DB::table('master_golongan')->pluck('golongan','id');
$jabatan = DB::table('master_jabatan')->pluck('nama_jabatan','id');
$unit_kerja = DB::table('master_unit_kerja')->pluck('unit_kerja','id');
$status_pegawai = DB::table('master_status_pegawai')->whereIn('id',[3,4])->pluck('status_pegawai','id');
//dd($pns);
return view('admin/edit/edit_pns', ['pns' => $pns ,'golongan'=>$golongan,
'jabatan'=>$jabatan,'unit_kerja'=>$unit_kerja,'agama'=>$agama,'status_pegawai'=>$status_pegawai]);
}
and its my controller to store data to update
public function update_pns(Request $request,$id)
{
$pns = User::find($id);
$pns->nama = $request->input('nama');
$pns->email = $request->input('email');
$pns->alamat = $request->input('alamat');
$pns->NIK = $request->input('NIK');
$pns->tempat_lahir = $request->input('tempat_lahir');
$pns->tanggal_lahir = $request->input('tanggal_lahir');
$pns->pendidikan = $request->input('pendidikan');
$pns->nomor = $request->input('nomor');
$pns->agama_id = $request->input('agama_id') ;
$pns->status_pegawai_id = $request->input('status_pegawai_id');
$pns->unit_kerja_id = $request->input('unit_kerja_id') ;
dd($pns);
// $pns->update();
// return redirect('pns1')->with('success', 'Your info are updated');
}
and its this route
Route::get('/edit_pns/{id}', 'AdminController#edit_pns' );
Route::post('/update/{id}', 'AdminController#update_pns')->name('update_pns');
whats wrong about this ?
UPDATE
<form method="POST" action="{{ route('update_pns') }}" class="form-horizontal form-label-left">
#csrf
<span class="section">Lengkapi Form Dibawah ini :</span>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="nama">NAMA <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="nama" type="text" class="form-control #error('nama') is-invalid #enderror" name="nama" value="{{$pns->users->nama}}" required autocomplete="nama">
#error('nama')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="NIK">NIK <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="NIK" type="text" class="form-control #error('NIK') is-invalid #enderror" name="NIK" value="{{$pns->users->NIK}}" required autocomplete="NIK" placeholder="3314********">
#error('NIK')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Email <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{$pns->users->email}}" required autocomplete="email" placeholder="contoh#gmail.com" required>
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tempat_lahir">Tempat Lahir <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="tempat_lahir" type="text" class="form-control #error('tempat_lahir') is-invalid #enderror" name="tempat_lahir" value="{{$pns->users->tempat_lahir}}" required autocomplete="tempat_lahir">
#error('tempat_lahir')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tanggal_lahir">Tanggal Lahir <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="tanggal_lahir" type="date" class="form-control #error('tanggal_lahir') is-invalid #enderror" name="tanggal_lahir" value="{{$pns->users->getOriginal('tanggal_lahir')}}" required autocomplete="tanggal_lahir">
#error('tanggal_lahir')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label for="jenis_kelamin" class="control-label col-md-3">Jenis Kelamin <span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<td>
<label> Laki-Laki<input type="radio" name="jenis_kelamin" value="L" checked>
</label>
</td>
<td>
<label> Perempuan
<input type="radio" name="jenis_kelamin" value="P">
</label>
</td>
#error('jenis_kelamin')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="pendidikan">Pendidikan Terakhir <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="pendidikan" type="text" class="form-control #error('pendidikan') is-invalid #enderror" name="pendidikan" value="{{$pns->users->pendidikan}}" required autocomplete="pendidikan">
#error('pendidikan')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="nomor">Nomor HP <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="nomor" type="text" class="form-control #error('nomor') is-invalid #enderror" name="nomor" value="{{$pns->users->nomor}}" required autocomplete="nomor" placeholder="contoh 628572510294">
#error('nomor')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Agama <span class="required">*</span></label>
<div class="col-md-6 col-sm-9 col-xs-12">
<select name="agama_id" id="agama_id" class="form-control">
#foreach($agama as $masters => $agamas )
<option value="{{ $masters }}" #if ($pns->users->agama_id == $masters ) selected #endif>{{ $agamas }}</option>
#endforeach
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="alamat">Alamat <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="alamat" required="required" name="alamat" value="" class="form-control col-md-7 col-xs-12">{{$pns->users->alamat}}</textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Unit Kerja <span class="required">*</span></label>
<div class="col-md-6 col-sm-9 col-xs-12">
<select name="unit_kerja_id" id="unit_kerja_id" class="form-control">
#foreach($unit_kerja as $units => $unit )
<option value="{{ $units }}" #if ($pns->users->unit_kerja_id == $units ) selected #endif>{{ $unit }}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Status Pegawai <span class="required">*</span></label>
<div class="col-md-6 col-sm-9 col-xs-12">
<select name="status_pegawai_id" id="status_pegawai_id" class="form-control">
#foreach($status_pegawai as $status => $pegawai )
<option value="{{ $status }}" #if ($pns->users->status_pegawai_id == $status ) selected #endif>{{ $pegawai }}</option>
#endforeach
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
<button id="send" type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
Your route require a parameter in order to be resolved, {id}, so instead of route('update_pns') inside the action of your form, you should have used route('update_pns', $idDesired) and instead of $idDesired, you should write the id you want to get on the update_pns method as $id
Since you're using request in your controller
Change your route to:
Route::post('/update', 'AdminController#update_pns')->name('update_pns');
And to your controller you can do this.
public function update_pns(Request $request)
{
$pns = User::find($request->id);
...
}
Also create a hidden input to your html to get the request id
<input tpye="hidden" value="{{ $id }}" name="id" />

how login/register from any page in laravel

I'm using Laravel 5.5 and I want to login/register from any page in my application and not to be require to load domain.com/login or domain.com/register for that.
PS: I'm using default authentication php artisan make:auth
Just copy the form content of login/Register page and paste it in your laravel page.
<form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : ''}}> Remember Me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Login
</button>
<a class="btn btn-link" href="{{ url('/password/reset') }}">
Forgot Your Password?
</a>
</div>
</div>
</form>

Laravel : How to show form error feedback of input that `type='file'`?

I am using Laravel 5.5 and bootstrap 4.0-beta .
How to show form error feedback of input that type='file'?
If input type='text',I can show error feedback like this:
<div class="form-group row">
<label for="username" class="col-2 col-form-label">username:</label>
<div class="col-10">
<input id="username" name="username" class="form-control {{ $errors->has('username') ? ' is-invalid' : '' }}" type="text" value="{{ old('username') }}">
#if ($errors->has('username'))
<div class="invalid-feedback">{{ $errors->first('username') }}</div>
#endif
</div>
</div>
question:
If input type='file', how to show error feedback? The code below does not work.
<div class="form-group row">
<label for="photo" class="col-2 col-form-label">photo:</label>
<div class="col-10">
<input type="file" id="photo" name="photo">
#if ($errors->has('photo'))
<div class="invalid-feedback">{{ $errors->first('photo') }}</div>
#endif
</div>
</div>
Try adding is-invalid class to the input.
<div class="form-group row">
<label for="photo" class="col-2 col-form-label">photo:</label>
<div class="col-10">
<input type="file" id="photo" name="photo" class="form-control {{ $errors->has('photo') ? ' is-invalid' : '' }}">
#if ($errors->has('photo'))
<div class="invalid-feedback">{{ $errors->first('photo') }}</div>
#endif
</div>
</div>

Laravel form displayed as raw text

My problem is probably related to server configuration problem. This is the issue. I am developing a Laravel website that works fine when developing on my local machine (using the laradock docker environment).
I wanted to run it on a small local machine so I turned on a fresh Ubuntu 16.04 server and installed docker on it. Checked out my code and ran composer install.
After going to the main registration page, I see that parts of the registration form are displayed as raw text :
I don't see any errors when using the developers page and also no errors in the php-fpm, workspace or nginx container from laradock that hosts the website.
Any idea?
code:
<?php
$ip = get_ip_address();
$countries = [
"Afghanistan" => "Afghanistan",
"Albania" => "Albania",
"Zimbabwe" => "Zimbabwe"
];
?>
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Register</div>
<div class="panel-body">
<form class="form-horizontal" role="form" method="POST" action="{{ route('register') }}">
{{ csrf_field() }}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>
#if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group">
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
</div>
</div>
<div class="form-group">
<label for="country" class="col-md-4 control-label">Select your country</label>
<div class="col-md-6">
{{Form::select("country", $countries, null, ['type' => 'text','class' => 'form-control','placeholder' => 'Pick your country...'])}}
</div>
#if ($errors->has('country'))
<span class="help-block">
<strong>{{ $errors->first('country') }}</strong>
</span>
#endif
</div>
{{ Form::hidden('ip', $ip) }}
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Register
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
<?php
function get_ip_address() {
// check for shared internet/ISP IP
if (!empty($_SERVER['HTTP_CLIENT_IP']) && validate_ip($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
}
// check for IPs passing through proxies
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// check if multiple ips exist in var
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== false) {
$iplist = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach ($iplist as $ip) {
if (validate_ip($ip))
return $ip;
}
} else {
if (validate_ip($_SERVER['HTTP_X_FORWARDED_FOR']))
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
}
if (!empty($_SERVER['HTTP_X_FORWARDED']) && validate_ip($_SERVER['HTTP_X_FORWARDED']))
return $_SERVER['HTTP_X_FORWARDED'];
if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && validate_ip($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && validate_ip($_SERVER['HTTP_FORWARDED_FOR']))
return $_SERVER['HTTP_FORWARDED_FOR'];
if (!empty($_SERVER['HTTP_FORWARDED']) && validate_ip($_SERVER['HTTP_FORWARDED']))
return $_SERVER['HTTP_FORWARDED'];
// return unreliable ip since all else failed
return $_SERVER['REMOTE_ADDR'];
}
?>
All the values echoed with {{ }} are sent through the htmlentities function of PHP. If you want to skip that, than you should use another notation:
{!! $unescaped_html !!}
Source

Resources