I have controller to input data to database and show error if duplicate data but i get message

> 
> Undefined variable: error
> 
> 
> 

```
$cek = DB::table('peserta')->where('email',$email)->count();
  if ($cek > 0 and count($error) > 0 ) {
    $pesan = [];
    $pesan['halu'] = 'danger';
    $pesan['message'] = 'Email anda sudah terdaftar';
  }

```