Package Data | |
---|---|
Maintainer Username: | patinthehat |
Maintainer Contact: | trick.developer@gmail.com (Patrick Organ) |
Package Create Date: | 2017-02-17 |
Package Last Update: | 2017-04-02 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:16:57 |
Package Statistics | |
---|---|
Total Downloads: | 18 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Various support classes for Laravel 5+.
####Installation
Install with composer:
composer require patinthehat/laravel-support
#####ExtendedSeeder
ExtendedSeeder is an extended version of the Seeder
class and provides easy foreign key check enable/disable and table truncating. It also allows for easy access to Faker.
######Methods
getFaker()
- returns an instance of Faker\Factory (see Faker).init($tableName, $disableForeignKeyChecks = true, $deleteAllTableEntries = true)
- call at the beginning of run()
.cleanup()
- call at the end of run()
.######Sample Usage:
use App\Support\ExtendedSeeder;
use App\User;
class UserTableSeeder extends ExtendedSeeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//disable foreign key checks, delete all existing table entries
$this->init('users', true, true);
//seed the table
$text = $this->getFaker()->text();
$this->cleanup();
}
}
#####ExtendedMigration
ExtendedMigration is an extended version of the Migration
class and provides easy foreign key creation/deletion.
######Sample Usage:
use LaravelSupport\Database\ExtendedMigration;
class CreateForeignKeys extends ExtendedMigration
{
//define the FKs
protected $foreignKeyDefinitions = [
'info.author_id' => ['authors.id', 'cascade', 'cascade'],
'info.book_id' => ['books.id', null, null],
'table2.test_id' => 'tests.id',
'myinfo.publisher_id' => null, //creates FK on 'publishers.id'
];
//automatically create/delete FKs
protected $autoCreateDefinedKeys = true;
protected $autoDeleteDefinedKeys = true;
}
LaravelSupport is available under the MIT License.