I need a bit of advice.
I have a few migrations files in my setup.
In some of them im seeing the following code which arent in the rest and im not sure what its for
use Illuminate\Database\Schema\Blueprint;
Schema::create('brand', function(Blueprint $table)
Could anyone tell me what the blueprint lines are for? as they arent in the other create table migrations.
Thanks
Blueprint is an open-source tool for rapidly generating multiple Laravel components from a single, human-readable definition. Blueprint works by using a draft file (YAML) that contains definitions of the components it should generate.
Laravel Migrations allow developers to programmatically create, update, and destroy database tables, working as a version control system for your database schema.
What is Laravel Migration? Laravel Migration is an essential feature in Laravel that allows you to create a table in your database. It allows you to modify and share the application's database schema. You can modify the table by adding a new column or deleting an existing column.
In Laravel, Migration provides a way for easily sharing the schema of the database. It also makes the modification of the schema much easier. It is like creating a schema once and then sharing it many times.
This is because in your closure the parameter $table
is tagged to be a Blueprint
object. In fact every time a Blueprint
is passed into the closure of Schema::create
.
So you can restrict the parameter to Blueprint
then PHP throws an fatal if an object of an other type is passed, or you can leave it blank so that PHP doesn't check the passed object.
Just look up the files where the use
-Statement is missing. There will be no parameter constraint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With