Resource > Page > Create fails
I have a resource created with the make:filament-resourse Donation --generate and all of actions work except for create.
I have also created a dozen other Resources using this pattern and they all work.
When I summit the create I'm receiving an SQL table doest exist. The table does exist and after I manually insert a record in the DB table the list and edit pages work.
I have compared the model to others, this Resource to others and found no differences other than the model/table name. I have checked to see if I have a pluralization issue and none found.
The sql error reads
SQLSTATE[HY000]: General error: 1 no such table:main. (Connection: sqlite, SQL: insert into "donations" and then the columns and correct data.
I have tried the various troubleshooting steps this discord channel mentions. I have also regenerated the resource and add, edit delete pages.
Any ideas?
24 Replies
Here is the full text and I'm not sure if this is a Filament, Livewire or Laravel issue.
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1 no such table: main. (Connection: sqlite, SQL: insert into "donations" ("donor_id", "date", "amount", "recurring", "notes", "donationtype_id", "updated_at", "created_at") values (1, 2025-04-07 10:49:14, 1, 0, ?, 1, 2025-04-07 17:49:25, 2025-04-07 17:49:25))
I have these other resources listed on the navigation pane working correctly and I have compared models, resources, pages etc.

The donations Listing View is from the manually inserted DB rows and uses the same Model.
My model is very simple

HAve you tried running the SQL Statement directly on the database.
Perhaps you have an errant trigger or something setup?
Can you share your migration file?
I see that your file name is
donation.php
, but it should be Donation.php
That is also why the class name is highlightedI just discovered that even from Tinker I can't insert a new record but can for other tables. I assume that this means I have an issue somewhere between the model and the table in the DB. When I tried to DB::table("Donations")->insert([....... it failed in the same way.
Please share your migration file. It’s sounds like the issue is there. But Matthew is also correct that the model file should be named Donation.php with a capital ‘D’ to conform with psr standards.
I have now corrected the case of the Model names (thank you both).
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Donation extends Model
{
use HasFactory, SoftDeletes;
protected $casts = [
'id' => 'integer',
'donor_id' => 'integer',
'date' => 'datetime',
'amount' => 'decimal:2',
'recurring' => 'boolean',
'donationtype_id' => 'integer',
];
public function donor(): BelongsTo
{
return $this->belongsTo(Donor::class);
}
public function donationtype(): BelongsTo
{
return $this->belongsTo(Donationtype::class);
}
}
Form I'm trying to submit:

Full error message

In my example both the donor_id and donationtype_id point to valid records in the associated tables. I have written plenty of Laravel code over the past 4 years but for the life of me I cant see what I missed.
I used Blueprint package to generate my models and migration files.
Need to see the migration file.
I added it just before the screenshot of the Create Donation form.
That's the model ?
Sorry I'm an idiot, I opened the migration but copied the model.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/
* Run the migrations.
*/
public function up(): void
{
Schema::disableForeignKeyConstraints();
Schema::create('donations', function (Blueprint $table) {
$table->id();
$table->foreignId('donor_id')->constrained();
$table->dateTime('date');
$table->decimal('amount', 8, 2);
$table->boolean('recurring')->default(false);
$table->text('notes')->nullable();
$table->foreignId('donationtype_id')->constrained('');
$table->timestamps();
$table->softDeletes();
});
Schema::enableForeignKeyConstraints();
}
/
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('donations');
}
};
This is from PhpStorm's dictionary query.

The migration file I listed was generated by Blueprint but the donationtype_id constrained seems to be formatted with a ('') whereas the donor_id is not.
Try that
Matthew, you are a beautiful person. Thank you for your assistance. This was in fact the issue!!
Thank you @Matthew
The clash of the 2 Matthew's 🤣
lol. Sorry.
This is my brother Doug, and this is my other brother Doug.
🙂