Repository navigation
Expand file tree
/
Copy pathForeignKeyDefinition.php
More file actions
90 lines (79 loc) · 2.27 KB
/
Copy pathForeignKeyDefinition.php
File metadata and controls
90 lines (79 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Database\Schema;
use Hyperf\Support\Fluent;
/**
* @method ForeignKeyDefinition references(array|string $columns) Specify the referenced column(s)
* @method ForeignKeyDefinition on(string $table) Specify the referenced table
* @method ForeignKeyDefinition onDelete(string $action) Add an ON DELETE action
* @method ForeignKeyDefinition onUpdate(string $action) Add an ON UPDATE action
* @method ForeignKeyDefinition deferrable(bool $value = true) Set the foreign key as deferrable (PostgreSQL)
* @method ForeignKeyDefinition initiallyImmediate(bool $value = true) Set the default time to check the constraint (PostgreSQL)
*/
class ForeignKeyDefinition extends Fluent
{
/**
* Indicate that updates should cascade.
*/
public function cascadeOnUpdate(): static
{
return $this->onUpdate('cascade');
}
/**
* Indicate that updates should be restricted.
*/
public function restrictOnUpdate(): static
{
return $this->onUpdate('restrict');
}
/**
* Indicate that updates should set the foreign key value to null.
*/
public function nullOnUpdate(): static
{
return $this->onUpdate('set null');
}
/**
* Indicate that updates should have "no action".
*/
public function noActionOnUpdate(): static
{
return $this->onUpdate('no action');
}
/**
* Indicate that deletes should cascade.
*/
public function cascadeOnDelete(): static
{
return $this->onDelete('cascade');
}
/**
* Indicate that deletes should be restricted.
*/
public function restrictOnDelete(): static
{
return $this->onDelete('restrict');
}
/**
* Indicate that deletes should set the foreign key value to null.
*/
public function nullOnDelete(): static
{
return $this->onDelete('set null');
}
/**
* Indicate that deletes should have "no action".
*/
public function noActionOnDelete(): static
{
return $this->onDelete('no action');
}
}