1. Go to this page and download the library: Download fndmiranda/data-migration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fndmiranda / data-migration example snippets
namespace App\DataMigrations;
use Fndmiranda\DataMigration\Contracts\DataMigration;
class PermissionDataMigration implements DataMigration
{
/**
* Order to execute this data-migration.
*
* @var int
*/
protected $order = 0;
/**
* Tag to filter on data-migrations search.
*
* @var string
*/
protected $tag = 'production';
/**
* Get the model being used by the data migration.
*
* @return string
*/
public function model()
{
//
}
/**
* Get the data being used by the data migration.
*
* @return mixed
*/
public function data()
{
//
}
/**
* Get the data options being used by the data migration.
*
* @return mixed
*/
public function options()
{
//
}
}
/**
* Get the model being used by the data migration.
*
* @return string
*/
public function model()
{
return \App\Permission::class;
}
/**
* Get the data options being used by the data migration.
*
* @return mixed
*/
public function options()
{
return [
'identifier' => 'name',
'show' => ['name', 'title'],
];
}
namespace App;
use Illuminate\Database\Eloquent\Model;
class Permission extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'title', 'group', 'brand_id',
];
/**
* The dependencies that belong to the permission.
*/
public function dependencies()
{
return $this->belongsToMany(Permission::class)->withPivot(['pivot_example_1', 'pivot_example_2']);
}
/**
* Get the brand of the permission.
*/
public function brand()
{
return $this->belongsTo(Brand::class);
}
}