obsidian/MyObsidianVault/Knowledgebase/WebDev/2 CodeIgniter/API Project setup/05.) Create Domain Model+Controller+Migration.md
2024-12-22 14:02:54 +01:00

683 B

php spark make:model Board --suffix
php spark make:controller Api/Board --suffix --restful

Add allowed fields to model: (BoardModel.php)

$allowedFields = ["name"];
php spark make:migration create_boards

Migration file:

//up:
	$this->forge->addField([
							"id" =>   [ "type"=>"INT", "constraint"=>5, "auto increment" => true, "unsigned" => true ],
							"name" => [ "type"=>"VARCHAR", "constraint" => 120, "null" => false ]
						  ]);
	$this->forge->addPrimaryKey("id);
	$this->forge->createTable("boards");

//down:
	$this->forge->dropTable("boards");
php spark migrate:status

php spark migrate

Create seeder ?