lukeraymonddowning / honey

A spam prevention package for Laravel, providing honeypot techniques, ip blocking and beautifully simple Recaptcha integration. Stop spam. Use Honey.
MIT License
398 stars 23 forks source link

Installing problem #25

Closed StrangerGithuber closed 3 years ago

StrangerGithuber commented 3 years ago

Hello I am using laravel 8.20.1 version and I have problem with this package. I am using the livewire (well learning) and I followed the steps in the documentation but the migration is doesn't work.

I just did:

  1. composer require lukeraymonddowning/honey
  2. php artisan honey:install
  3. php artisan migrate

And I get to the last command this message: "Nothing to migrate."

I tried to copy the migration spammer file to the main migration folder too but then I got many errors because "config('honey.spammer_blocking.table_name')" part is null for the laravel.

Exact error:

Migrating: 2020_11_26_000000_create_spammers_table

   Illuminate\Database\QueryException 

  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`id` bigint unsigned not null auto_increment primary key, `ip_address` varchar(255) not null, `attempts` int not null, `blocked
_at` datetime null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at C:\laragon\www\vendor\laravel\framework\src\Illuminate\Database\Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕

  1   C:\laragon\www\vendor\laravel\framework\src\Illuminate\Database\Connection.php:465
      PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")

  2   C:\laragon\www\vendor\laravel\framework\src\Illuminate\Database\Connection.php:465
      PDO::prepare("create table `` (`id` bigint unsigned not null auto_increment primary key, `ip_address` varchar(255) not null, `attempts` int not null, `blocked_at` datetime null, `created_at` timestamp null, `updated_at` timest
amp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")

What I should do?

Update: I tried to insert data with seeder to the spammers table after created manually:

<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Lukeraymonddowning\Honey\Models\Spammer;
use Faker\Factory as Faker;

class SpammerSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Faker::create();
        $settings = [
            'ip_address' => $faker->ipv4,
            'attempts' => $faker->numberBetween(0, 5),
            'blocked_at' => now()
        ];
        Spammer::Create($settings);
    }
}

Error:

  Illuminate\Database\QueryException 

  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: insert into `` (`ip_address`, `attempts`, `blocked_at`, `updated_at`, `created_at`) values (207.44.204.248, 4, 2021-01-04 19:42:53, 2021-01-04 1
9:42:53, 2021-01-04 19:42:53))

  at C:\laragon\www\vendor\laravel\framework\src\Illuminate\Database\Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕

  1   C:\laragon\www\vendor\laravel\framework\src\Illuminate\Database\Connection.php:465
      PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")

  2   C:\laragon\www\vendor\laravel\framework\src\Illuminate\Database\Connection.php:465
      PDO::prepare("insert into `` (`ip_address`, `attempts`, `blocked_at`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?)")

As if the config file is not working.

ashkesarmaa commented 3 years ago

I have a same issue i run php artisan migrate And I got this message: "Nothing to migrate."

rabol commented 3 years ago

php artisan vendor:publish and then select Provider: Lukeraymonddowning\Honey\Providers\HoneyServiceProvider that will publish the migration files

lukeraymonddowning commented 3 years ago

I'm going to close this issue, but feel free to reopen it if its still a problem. I can't reproduce on my end.