I don't think the
php artisan generate:pivot players teams
exists in Laravel 5 as it used to in Laravel 4.
Hopefully however, this may help. This is how I create pivot tables in Laravel 5 with foreign key constraints:
php artisan make:migration create_player_team_table --table=player_team
The most important thing is to ensure your player_team table name is in alphabetical order with singular table names, i.e. do not use teams_players (not alphabetical), and do not use something like, player_teams (the plural teams will break it.)
The following gives an example of how the resulting
###_##_##_######_create_player_team_table.php
up() function might look:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('player_team', function(Blueprint $table)
{
$table->increments('id');
$table->integer('player_id')->unsigned();
$table->integer('team_id')->unsigned();
$table->foreign('player_id')->references('id')->on('players')->onDelete('cascade');
$table->foreign('team_id')->references('id')->on('teams')->onDelete('cascade');
});
}
Obviously, you can include or exclude the foreign key cascading deletes if you wish, I include them here only as a pointer.
I hope this helps.
EDIT: In the doc of this package, the command is :
php artisan make:migration:pivot tags posts
Couldn't list the the pivot method in bash
I do however this error, probably because i have already set this up.
$ composer require laracasts/generators --dev Using version ^1.1 for laracasts/generators ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files
[Symfony\Component\Debug\Exception\FatalErrorException] Call to undefined method Illuminate\Foundation\Application::getCachedCompilePath()
Script php artisan clear-compiled handling the post-update-cmd event returned with an error
[RuntimeException] Error Output:
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [packages1] ... [packagesN]
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community