You set null come error?

|
YOUCODEWORLD 2021-05-31 18:39:53
But that’s okay. You keep complaining.
YOUCODEWORLD 2021-05-31 18:45:42
Dilawar Naseem 2021-05-31 18:38:35
Please check this video as i am working in laravel livewire with DOMPDF i am getting 404 Not Found Error Please help me in this error

Maybe you write route some wrong

YOUCODEWORLD 2021-05-31 18:48:31
Dilawar Naseem 2021-05-31 18:38:35
Please check this video as i am working in laravel livewire with DOMPDF i am getting 404 Not Found Error Please help me in this error

laravel_discuss-83578.jpg

SureshLaraDev 2021-05-31 19:03:07
hi guys..why this weird thing happens all time?
SureshLaraDev 2021-05-31 19:03:22
public function up()
{
Schema::create(‘dreams’, function (Blueprint $table) {
$table->bigIncrements(‘dream_id’);
$table->unsignedBigInteger(‘sup_id’);
$table->string(‘dream’);
$table->foreign(‘sup_id’)
->references(‘supp_id’)
->on(‘suppliers’)
->onDelete(‘set null’);
$table->timestamps();
});
}
SureshLaraDev 2021-05-31 19:03:37
Schema::create(‘suppliers’, function (Blueprint $table) {
$table->bigIncrements(‘supp_id’);
$table->string(‘supp_name’);
$table->string(‘supp_gstn’);
$table->unsignedBigInteger(‘supp_phone’);
$table->string(‘supp_email’);
$table->text(‘supp_address’);
$table->timestamps();
});
SureshLaraDev 2021-05-31 19:03:56
PDOException::(“SQLSTATE[HY000]: General error: 1005 Can’t create table autofill.dreams (errno: 150 “Foreign key constraint is incorrectly formed”)”)
YOUCODEWORLD 2021-05-31 19:06:12
SureshLaraDev 2021-05-31 19:03:22
public function up()
{
Schema::create(‘dreams’, function (Blueprint $table) {
$table->bigIncrements(‘dream_id’);
$table->unsignedBigInteger(‘sup_id’);
$table->string(‘dream’);
$table->foreign(‘sup_id’)
->references(‘supp_id’)
->on(‘suppliers’)
->onDelete(‘set null’);
$table->timestamps();
});
}

Here $table-> foreignId(‘sup_id’)
->references(‘supp_id’)
->on(‘suppliers’)
->onDelete(‘cascade’);

SureshLaraDev 2021-05-31 19:07:15
cascade is the problem>
YOUCODEWORLD 2021-05-31 19:08:22
You try more time
YOUCODEWORLD 2021-05-31 19:08:36
$table-> foreignId(‘sup_id’)
->references(‘supp_id’)
->on(‘suppliers’)
->onDelete(‘cascade’);
SureshLaraDev 2021-05-31 19:08:53
what if i have to set it to null instead of deleting it?
YOUCODEWORLD 2021-05-31 19:09:51
You undresstand what’s onDelete?
SureshLaraDev 2021-05-31 19:09:52
YOUCODEWORLD 2021-05-31 19:08:36
$table-> foreignId(‘sup_id’)
->references(‘supp_id’)
->on(‘suppliers’)
->onDelete(‘cascade’);

it works but what if i have to set it to null

SureshLaraDev 2021-05-31 19:10:19
yes..if dream gets deleted the supplier associated with it gets deleted
YOUCODEWORLD 2021-05-31 19:10:37
Yes
YOUCODEWORLD 2021-05-31 19:10:50
So cascade The onDelete(‘cascade’) means that when the row is deleted
SureshLaraDev 2021-05-31 19:11:21
there is this option for onDelete
SureshLaraDev 2021-05-31 19:11:35
‘set null’ how to use it?
YOUCODEWORLD 2021-05-31 19:11:36
Yes
SureshLaraDev 2021-05-31 19:11:52
for onDelete and onUpdate….how to use that.
YOUCODEWORLD 2021-05-31 19:12:18
->onUpdate(‘cascade’)
->onDelete(‘cascade’);
SureshLaraDev 2021-05-31 19:13:29
I know about cascade. I am asking about set null
YOUCODEWORLD 2021-05-31 19:13:56
SureshLaraDev 2021-05-31 19:11:35
‘set null’ how to use it?

You write near action set null

SureshLaraDev 2021-05-31 19:14:32
Ah ok thanks dude
YOUCODEWORLD 2021-05-31 19:15:29
SureshLaraDev 2021-05-31 19:14:32
Ah ok thanks dude

Or youcan use onDelete(‘set null’)

SureshLaraDev 2021-05-31 19:15:58
Lol.. That’s where this problem comes.
YOUCODEWORLD 2021-05-31 19:16:31
You problem foreign
SureshLaraDev 2021-05-31 19:16:37
SureshLaraDev 2021-05-31 19:03:22
public function up()
{
Schema::create(‘dreams’, function (Blueprint $table) {
$table->bigIncrements(‘dream_id’);
$table->unsignedBigInteger(‘sup_id’);
$table->string(‘dream’);
$table->foreign(‘sup_id’)
->references(‘supp_id’)
->on(‘suppliers’)
->onDelete(‘set null’);
$table->timestamps();
});
}

..

SureshLaraDev 2021-05-31 19:17:14
Migration acting weird..
YOUCODEWORLD 2021-05-31 19:17:27
It’n foreign , it is foreignId
SureshLaraDev 2021-05-31 19:17:46
The same migration worked with cascade. But not with set null
YOUCODEWORLD 2021-05-31 19:18:56
You set null come error?
SureshLaraDev 2021-05-31 19:19:02
If problem is with my foreign id.. Why it gets migrated when using onDelete(‘cascade’)
SureshLaraDev 2021-05-31 19:19:14
SureshLaraDev 2021-05-31 19:03:56
PDOException::(“SQLSTATE[HY000]: General error: 1005 Can’t create table autofill.dreams (errno: 150 “Foreign key constraint is incorrectly formed”)”)

..

|