Skip to content
This repository was archived by the owner on Mar 26, 2022. It is now read-only.

Commit 406c130

Browse files
luksan47kdmnk
andauthored
Set status for collegists (#462)
* Set status for collegists * Apply fixes from StyleCI * detach role * Apply fixes from StyleCI Co-authored-by: Norbert Luksa <[email protected]> Co-authored-by: Katkó Dominik <[email protected]> Co-authored-by: Katkó Dominik <[email protected]>
1 parent 3ab0f83 commit 406c130

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use App\Models\Role;
4+
use App\Models\Semester;
5+
use App\Models\User;
6+
use Illuminate\Database\Migrations\Migration;
7+
8+
class SetCollegistStatus extends Migration
9+
{
10+
/**
11+
* Run the migrations.
12+
*
13+
* @return void
14+
*/
15+
public function up()
16+
{
17+
$collegists = User::collegists();
18+
foreach ($collegists as $collegist) {
19+
$extern_id = Role::getObjectIdByName(Role::COLLEGIST, 'extern');
20+
$collegist->roles()->detach(Role::getId(Role::COLLEGIST));
21+
$collegist->roles()->attach(Role::getId(Role::COLLEGIST), ['object_id' => $extern_id]);
22+
$collegist->setStatusFor(Semester::current(), Semester::ACTIVE);
23+
}
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
//
34+
}
35+
}

0 commit comments

Comments
 (0)