engine = 'InnoDB'; // Specify the table storage engine (MySQL). $table->charset = 'utf8'; // Specify a default character set for the table (MySQL). $table->collation = 'utf8_unicode_ci'; // Specify a default collation for the table (MySQL). $table->temporary(); // Create a temporary table (except SQL Server). // COLUMN TYPES $table->bigIncrements('id'); // Auto-incrementing UNSIGNED BIGINT (primary key) equivalent column. $table->bigInteger('votes'); // BIGINT equivalent column. $table->binary('data'); // BLOB equivalent column. $table->boolean('confirmed'); // BOOLEAN equivalent column. $table->char('name', 100); // CHAR equivalent column with an optional length. $table->date('created_at'); // DATE equivalent column. $table->dateTime('created_at'); // DATETIME equivalent column. $table->dateTimeTz('created_at'); // DATETIME (with timezone) equivalent column. $table->decimal('amount', 8, 2); // DECIMAL equivalent column with a precision (total digits) and scale (decimal digits). $table->double('amount', 8, 2); // DOUBLE equivalent column with a precision (total digits) and scale (decimal digits). $table->enum('level', ['easy', 'hard']); // ENUM equivalent column. $table->float('amount', 8, 2); // FLOAT equivalent column with a precision (total digits) and scale (decimal digits). $table->geometry('positions'); // GEOMETRY equivalent column. $table->geometryCollection('positions'); // GEOMETRYCOLLECTION equivalent column. $table->increments('id'); // Auto-incrementing UNSIGNED INTEGER (primary key) equivalent column. $table->integer('votes'); // INTEGER equivalent column. $table->ipAddress('visitor'); // IP address equivalent column. $table->json('options'); // JSON equivalent column. $table->jsonb('options'); // JSONB equivalent column. $table->lineString('positions'); // LINESTRING equivalent column. $table->longText('description'); // LONGTEXT equivalent column. $table->macAddress('device'); // MAC address equivalent column. $table->mediumIncrements('id'); // Auto-incrementing UNSIGNED MEDIUMINT (primary key) equivalent column. $table->mediumInteger('votes'); // MEDIUMINT equivalent column. $table->mediumText('description'); // MEDIUMTEXT equivalent column. $table->morphs('taggable'); // Adds taggable_id UNSIGNED BIGINT and taggable_type VARCHAR equivalent columns. $table->uuidMorphs('taggable'); // Adds taggable_id CHAR(36) and taggable_type VARCHAR(255) UUID equivalent columns. $table->multiLineString('positions'); // MULTILINESTRING equivalent column. $table->multiPoint('positions'); // MULTIPOINT equivalent column. $table->multiPolygon('positions'); // MULTIPOLYGON equivalent column. $table->nullableMorphs('taggable'); // Adds nullable versions of morphs() columns. $table->nullableUuidMorphs('taggable'); // Adds nullable versions of uuidMorphs() columns. $table->nullableTimestamps(); // Alias of timestamps() method. $table->point('position'); // POINT equivalent column. $table->polygon('positions'); // POLYGON equivalent column. $table->rememberToken(); // Adds a nullable remember_token VARCHAR(100) equivalent column. $table->set('flavors', ['strawberry', 'vanilla']); // SET equivalent column. $table->smallIncrements('id'); // Auto-incrementing UNSIGNED SMALLINT (primary key) equivalent column. $table->smallInteger('votes'); // SMALLINT equivalent column. $table->softDeletes(); // Adds a nullable deleted_at TIMESTAMP equivalent column for soft deletes. $table->softDeletesTz(); // Adds a nullable deleted_at TIMESTAMP (with timezone) equivalent column for soft deletes. $table->string('name', 100); // VARCHAR equivalent column with a optional length. $table->text('description'); // TEXT equivalent column. $table->time('sunrise'); // TIME equivalent column. $table->timeTz('sunrise'); // TIME (with timezone) equivalent column. $table->timestamp('added_on'); // TIMESTAMP equivalent column. $table->timestampTz('added_on'); // TIMESTAMP (with timezone) equivalent column. $table->timestamps(); // Adds nullable created_at and updated_at TIMESTAMP equivalent columns. $table->timestampsTz(); // Adds nullable created_at and updated_at TIMESTAMP (with timezone) equivalent columns. $table->tinyIncrements('id'); // Auto-incrementing UNSIGNED TINYINT (primary key) equivalent column. $table->tinyInteger('votes'); // TINYINT equivalent column. $table->unsignedBigInteger('votes'); // UNSIGNED BIGINT equivalent column. $table->unsignedDecimal('amount', 8, 2); // UNSIGNED DECIMAL equivalent column with a precision (total digits) and scale (decimal digits). $table->unsignedInteger('votes'); // UNSIGNED INTEGER equivalent column. $table->unsignedMediumInteger('votes'); // UNSIGNED MEDIUMINT equivalent column. $table->unsignedSmallInteger('votes'); // UNSIGNED SMALLINT equivalent column. $table->unsignedTinyInteger('votes'); // UNSIGNED TINYINT equivalent column. $table->uuid('id'); // UUID equivalent column. $table->year('birth_year'); // YEAR equivalent column. // COLUMN MODIFIERS $table->someType()->after('column'); // Place the column "after" another column (MySQL) $table->someType()->autoIncrement(); // Set INTEGER columns as auto-increment (primary key) $table->someType()->charset('utf8'); // Specify a character set for the column (MySQL) $table->someType()->collation('utf8_unicode_ci'); // Specify a collation for the column (MySQL/SQL Server) $table->someType()->comment('my comment'); // Add a comment to a column (MySQL/PostgreSQL) $table->someType()->default($value); // Specify a "default" value for the column $table->someType()->first(); // Place the column "first" in the table (MySQL) $table->someType()->nullable($value = true); // Allows (by default) NULL values to be inserted into the column $table->someType()->storedAs($expression); // Create a stored generated column (MySQL) $table->someType()->unsigned(); // Set INTEGER columns as UNSIGNED (MySQL) $table->someType()->useCurrent(); // Set TIMESTAMP columns to use CURRENT_TIMESTAMP as default value $table->someType()->virtualAs($expression); // Create a virtual generated column (MySQL) $table->someType()->generatedAs($expression); // Create an identity column with specified sequence options (PostgreSQL) $table->someType()->always(); // Defines the precedence of sequence values over input for an identity column (PostgreSQL) // UPDATING COLUMNS $table->someType()->change(); // Allows you to modify some existing column types to a new type or modify the column's attributes. $table->renameColumn('from', 'to'); // Rename a column $table->dropColumn('column'); // Drop a given column (accepts an array of columns). $table->dropRememberToken(); // Drop the remember_token column. $table->dropSoftDeletes(); // Drop the deleted_at column. $table->dropSoftDeletesTz(); // Alias of dropSoftDeletes() method. $table->dropTimestamps(); // Drop the created_at and updated_at columns. $table->dropTimestampsTz(); // Alias of dropTimestamps() method. // INDEXES $table->primary('id'); // Adds a primary key. $table->primary(['id', 'parent_id']); // Adds composite keys. $table->unique('email'); // Adds a unique index. $table->index('state'); // Adds a plain index. $table->spatialIndex('location'); // Adds a spatial index. (except SQLite) $table->dropPrimary('users_id_primary'); // Drop a primary key from the "users" table. $table->dropUnique('users_email_unique'); // Drop a unique index from the "users" table. $table->dropIndex('geo_state_index'); // Drop a basic index from the "geo" table. $table->dropSpatialIndex('geo_location_spatialindex'); // Drop a spatial index from the "geo" table (except SQLite). // FOREIGN KEY CONSTRAINTS $table->foreign('user_id')->references('id')->on('users'); // Create foreign key constraints. $table->dropForeign('posts_user_id_foreign'); // Drop foreign key (accepts an array of strings). Schema::enableForeignKeyConstraints(); // Enable foreign key constraints within your migrations. Schema::disableForeignKeyConstraints(); // Disable foreign key constraints within your migrations. /******************************************************************************************** * COLLECTION ELOQUENT METHODS * https://laravel.com/docs/5.7/collections ********************************************************************************************/ all average avg chunk collapse combine concat contains containsStrict count crossJoin dd diff diffAssoc diffKeys dump each eachSpread every except filter first firstWhere flatMap flatten flip forget forPage get groupBy has implode intersect intersectByKeys isEmpty isNotEmpty keyBy keys last macro make map mapInto mapSpread mapToGroups mapWithKeys max median merge min mode nth only pad partition pipe pluck pop prepend pull push put random reduce reject reverse search shift shuffle slice some sort sortBy sortByDesc sortKeys sortKeysDesc splice split sum take tap times toArray toJson transform union unique uniqueStrict unless unlessEmpty unlessNotEmpty unwrap values when whenEmpty whenNotEmpty where whereStrict whereBetween whereIn whereInStrict whereInstanceOf whereNotBetween whereNotIn whereNotInStrict wrap zip /******************************************************************************************** * HTTP TESTS * https://laravel.com/docs/5.7/http-tests ********************************************************************************************/ $response->assertStatus($code); // Assert that the response has a given code. $response->assertForbidden(); // Assert that the response has a forbidden status code. $response->assertNotFound(); // Assert that the response has a not found status code. $response->assertOk(); // Assert that the response has a 200 status code. $response->assertSuccessful(); // Assert that the response has a successful status code. $response->assertRedirect($uri); // Assert that the response is a redirect to a given URI. $response->assertHeader($headerName, $value = null); // Assert that the given header is present on the response. $response->assertHeaderMissing($headerName); // Assert that the given header is not present on the response. $response->assertExactJson(array $data); // Assert that the response contains an exact match of the given JSON data. $response->assertJson(array $data); // Assert that the response contains the given JSON data. $response->assertJsonCount($count, $key = null); // Assert that the response JSON has an array with the expected number of items at the given key. $response->assertJsonFragment(array $data); // Assert that the response contains the given JSON fragment. $response->assertJsonMissing(array $data); // Assert that the response does not contain the given JSON fragment. $response->assertJsonMissingExact(array $data); // Assert that the response does not contain the exact JSON fragment. $response->assertJsonMissingValidationErrors($keys); // Assert that the response has no JSON validation errors for the given keys. $response->assertJsonStructure(array $structure); // Assert that the response has a given JSON structure. $response->assertJsonValidationErrors($keys); // Assert that the response has the given JSON validation errors for the given keys. $response->assertDontSee($value); // Assert that the given string is not contained within the response. $response->assertDontSeeText($value); // Assert that the given string is not contained within the response text. $response->assertSee($value); // Assert that the given string is contained within the response. $response->assertSeeInOrder(array $values); // Assert that the given strings are contained in order within the response. $response->assertSeeText($value); // Assert that the given string is contained within the response text. $response->assertSeeTextInOrder(array $values); // Assert that the given strings are contained in order within the response text. $response->assertCookie($cookieName, $value = null); // Assert that the response contains the given cookie. $response->assertCookieExpired($cookieName); // Assert that the response contains the given cookie and it is expired. $response->assertCookieNotExpired($cookieName); // Assert that the response contains the given cookie and it is not expired. $response->assertCookieMissing($cookieName); // Assert that the response does not contains the given cookie. $response->assertPlainCookie($cookieName, $value = null); // Assert that the response contains the given cookie (unencrypted). $response->assertSessionHas($key, $value = null); // Assert that the session contains the given piece of data. $response->assertSessionHasAll(array $data); // Assert that the session has a given list of values. $response->assertSessionHasErrors(array $keys, $format = null, $errorBag = 'default'); // Assert that the session contains an error for the given field. $response->assertSessionHasErrorsIn($errorBag, $keys = [], $format = null); // Assert that the session has the given errors. $response->assertSessionHasNoErrors(); // Assert that the session has no errors. $response->assertSessionDoesntHaveErrors($keys = [], $format = null, $errorBag = 'default'); // Assert that the session has no errors for the given keys. $response->assertSessionMissing($key); // Assert that the session does not contain the given key. $response->assertViewHas($key, $value = null); // Assert that the response view was given a piece of data. $response->assertViewHasAll(array $data); // Assert that the response view has a given list of data. $response->assertViewIs($value); // Assert that the given view was returned by the route. $response->assertViewMissing($key); // Assert that the response view is missing a piece of bound data. $this->assertAuthenticated($guard = null); // Assert that the user is authenticated. $this->assertGuest($guard = null); // Assert that the user is not authenticated. $this->assertAuthenticatedAs($user, $guard = null); // Assert that the given user is authenticated. $this->assertCredentials(array $credentials, $guard = null); // $this->assertCredentials(array $credentials, $guard = null). $this->assertInvalidCredentials(array $credentials, $guard = null); // Assert that the given credentials are invalid. /******************************************************************************************** * LARAVEL VALET COMMANDS * https://laravel.com/docs/6.0/valet ********************************************************************************************/ valet install // Install the Valet daemon. valet uninstall // Uninstall the Valet daemon. valet use php@7.2 // Allows you to switch between php versions. valet start // Start the Valet daemon. valet stop // Stop the Valet daemon. valet restart // Restart the Valet daemon. valet park // Register your current working directory as a path which Valet should search for sites. valet forget // Run this command from a "parked" directory to remove it from the parked directory list. valet paths // View all of your "parked" paths. valet link // Link a single site in the current directory and not the entire directory. valet unlink // Unlink a single site in the current directory valet links // View all of your "linked" paths. valet secure // Serve site into https valet unsecure // Revert back to http valet log // View a list of logs which are written by Valet's services. valet trust // Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for passwords. valet tld // Update tld for your domains (default to test). valet share // Share your site with the world.