Dale
Resource > Page > Create fails
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');
}
};
31 replies
Resource > Page > Create fails
<?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);
}
}
31 replies
Resource > Page > Create fails
I 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.
31 replies
Resource > Page > Create fails
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))
31 replies