| Total Complexity | 1 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class DatabaseUserPerissionsSeeder extends Seeder |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * Run the database seeds. |
||
| 10 | * |
||
| 11 | * @return void |
||
| 12 | */ |
||
| 13 | public function run() |
||
| 14 | { |
||
| 15 | |||
| 16 | $user_model = config('dbm.user.model'); |
||
| 17 | $user_table = config('dbm.user.table'); |
||
| 18 | $user_local_key = config('dbm.user.local_key'); |
||
| 19 | $user_display_name = config('dbm.user.display_name'); |
||
| 20 | $where = config('dbm.user.where'); |
||
| 21 | |||
| 22 | $user = $user_model::where($where)->first(); |
||
| 23 | |||
| 24 | $localModel = Manager::model($user_model, $user_table) |
||
| 25 | ->where($user_local_key, $user->{$user_local_key}) |
||
| 26 | ->first(); |
||
| 27 | $permissions = Manager::Permission()->all(); |
||
| 28 | Manager::Object() |
||
| 29 | ->setManyToManyRelation( |
||
| 30 | $localModel, |
||
| 31 | Manager::Permission(), |
||
| 32 | 'dbm_user_permissions', |
||
| 33 | 'user_id', |
||
| 34 | 'dbm_permission_id' |
||
| 35 | ) |
||
| 36 | ->belongs_to_many() |
||
| 37 | ->sync($permissions); |
||
| 38 | } |
||
| 40 |