Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Dev" #2540

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/AmbassadorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function index(UserFilters $filters)
return redirect('ambassadors?country_iso='.$country_iso);
}

$ambassadors = User::role('ambassador')->filter($filters)->whereNotNull('avatar_path')->whereNotNull('bio')->get();
$ambassadors = User::role('ambassador')->filter($filters)->whereNotNull('avatar_path')->whereNotNull('bio')->paginate(10);

return view('ambassadors')->with([
'ambassadors' => $ambassadors,
Expand Down
8 changes: 1 addition & 7 deletions app/Http/Controllers/CommunityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ public function index(UserFilters $filters)
return redirect('community?country_iso='.$country_iso);
}

$ambassadors = User::role('ambassador')
->filter($filters)
->whereNotNull('avatar_path')
->whereNotNull('bio')
->whereNotNull('city_id') // Ensure city is set
->with('city') // Load city details
->get();
$ambassadors = User::role('ambassador')->filter($filters)->whereNotNull('avatar_path')->whereNotNull('bio')->paginate(10);

$teachers = User::role('leading teacher')->where('approved', 1)->with('city')->get();

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function index(Request $request): View
[
'title' => 'Girls in Digital',
'description' => 'Explore and embrace digital opportunities—empowering a new generation of girls in digital!',
'url' => 'https://codeweek.eu/girls-in-digital-week',
'url' => 'https://codeweek.eu/blog/girls-in-digital-week/',
'style_color' => 'background-image: linear-gradient(36.92deg, #1C4DA1 20.32%, #0040AE 28.24%);',
'btn_lang' => 'home.get_involved',
],
Expand Down
14 changes: 7 additions & 7 deletions database/seeders/CountrySeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Country; // Ensure correct model namespace

class CountrySeeder extends Seeder
{
Expand All @@ -25,7 +23,11 @@ public function run(): void
['iso' => 'EE', 'name' => 'Estonia', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'FI', 'name' => 'Finland', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'FR', 'name' => 'France', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'GF', 'name' => 'French Guiana', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'PF', 'name' => 'French Polynesia', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'TF', 'name' => 'French Southern Territories', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'DE', 'name' => 'Germany', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'GI', 'name' => 'Gibraltar', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'GR', 'name' => 'Greece', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'IE', 'name' => 'Ireland', 'longitude' => '1.234', 'latitude' => '5.678'],
['iso' => 'IT', 'name' => 'Italy', 'longitude' => '1.234', 'latitude' => '5.678'],
Expand All @@ -38,13 +40,11 @@ public function run(): void
['iso' => 'ES', 'name' => 'Spain', 'longitude' => '1.234', 'latitude' => '5.678'],
];

//dd($countries[0]["iso"]);

foreach ($countries as $country) {
Country::updateOrCreate(
['iso' => $country['iso']], // Ensure uniqueness by ISO code
$country
);
factory(App\Country::class)->create($country);
}

$this->command->info("✅ Countries seeded successfully!");
}
}
19 changes: 5 additions & 14 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,17 @@ class DatabaseSeeder extends Seeder
public function run(): void
{

$this->call(CountriesTableSeeder::class);
$this->call(CitiesTableSeeder::class);

// Roles, permissions, users
//$this->call(CountriesTableSeeder::class);
//$this->call(CitiesTableSeeder::class);
$this->call(RolesAndPermissionsSeeder::class);
$this->call(LeadingTeacherRoleSeeder::class);
$this->call(UserSeeder::class);

// Additional data
$this->call(AudienceTableSeeder::class);
$this->call(ThemeTableSeeder::class);
$this->call(EventSeeder::class);
$this->call(OldSeeder::class);
// ... and so on

// Resource seeders
$this->call(ResourceEditorRoleSeeder::class);

$this->call(SchoolSeeder::class);
//$this->call(ResourceSeeder::class);

//$this->call(OldSeeder::class);
//$this->call(EventSeeder::class);

}
}
59 changes: 40 additions & 19 deletions database/seeders/LeadingTeacherExpertiseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,46 @@ class LeadingTeacherExpertiseSeeder extends Seeder
*/
public function run(): void
{
// Ensure data is seeded only if it doesn't already exist
$expertises = [
['position' => 10, 'name' => 'Teacher Trainer'],
['position' => 20, 'name' => 'Community Organiser'],
['position' => 30, 'name' => 'Expert in unplugged programming'],
['position' => 40, 'name' => 'Expert in Scratch'],
['position' => 50, 'name' => 'Expert in Robotics'],
['position' => 60, 'name' => 'Expert in programming (Python, C++, SQL, etc.)'],
['position' => 70, 'name' => 'Expert in remote/hybrid teaching'],
['position' => 80, 'name' => 'Expert in use of remote teaching platforms'],
];
create(LeadingTeacherExpertise::class, [
'id' => 1,
'position' => 10,
'name' => 'Teacher Trainer',
]);
create(LeadingTeacherExpertise::class, [
'id' => 2,
'position' => 20,
'name' => 'Community Organiser',
]);
create(LeadingTeacherExpertise::class, [
'id' => 3,
'position' => 30,
'name' => 'Expert in unplugged programming',
]);
create(LeadingTeacherExpertise::class, [
'id' => 4,
'position' => 40,
'name' => 'Expert in Scratch',
]);
create(LeadingTeacherExpertise::class, [
'id' => 5,
'position' => 50,
'name' => 'Expert in Robotics',
]);
create(LeadingTeacherExpertise::class, [
'id' => 6,
'position' => 60,
'name' => 'Expert in programming (Python, C++, SQL, etc.)',
]);
create(LeadingTeacherExpertise::class, [
'id' => 7,
'position' => 70,
'name' => 'Expert in remote/hybrid teaching',
]);
create(LeadingTeacherExpertise::class, [
'id' => 8,
'position' => 80,
'name' => 'Expert in use of remote teaching platforms',
]);

foreach ($expertises as $expertise) {
LeadingTeacherExpertise::updateOrCreate(
['name' => $expertise['name']], // Check for existing entry by name
['position' => $expertise['position']]
);
}

$this->command->info("✅ Leading teacher expertises seeded successfully!");
}
}
15 changes: 6 additions & 9 deletions database/seeders/LeadingTeacherRoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ public function run(): void
// Reset cached roles and permissions
app()['cache']->forget('spatie.permission.cache');

// Check if permission already exists before creating
$permission = Permission::firstOrCreate(['name' => 'submit resource']);
// create permissions
Permission::create(['name' => 'submit resource']);

// Check if role already exists before creating
$leadingTeacherRole = Role::firstOrCreate(['name' => 'leading teacher']);
if (!$leadingTeacherRole->hasPermissionTo($permission)) {
$leadingTeacherRole->givePermissionTo($permission);
}
// create roles and assign created permissions
$leadingTeacherRole = Role::create(['name' => 'leading teacher']);
$leadingTeacherRole->givePermissionTo(['submit resource']);

Role::firstOrCreate(['name' => 'leading teacher admin']);
$leadingTeacherAdminRole = Role::create(['name' => 'leading teacher admin']);

$this->command->info("✅ Leading Teacher roles and permissions seeded successfully!");
}
}
58 changes: 1 addition & 57 deletions database/seeders/LeadingTeacherSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\User;
use Spatie\Permission\Models\Role;
use Illuminate\Support\Facades\File;

class LeadingTeacherSeeder extends Seeder
{
Expand All @@ -14,63 +11,10 @@ class LeadingTeacherSeeder extends Seeder
*/
public function run(): void
{
// Call related seeders first

$this->call(LeadingTeacherRoleSeeder::class);
$this->call(CitiesTableSeeder::class);
$this->call(LeadingTeacherExpertiseSeeder::class);

// Load JSON File
$jsonPath = storage_path('app/leading_teachers.json');

if (!File::exists($jsonPath)) {
$this->command->error("❌ JSON file not found: $jsonPath");
return;
}

// Decode JSON
$jsonData = File::get($jsonPath);
$teachers = json_decode($jsonData, true);

if (!$teachers) {
$this->command->error("❌ Invalid JSON structure.");
return;
}

// Get the "leading teacher" role
$role = Role::where('name', 'leading teacher')->first();
if (!$role) {
$this->command->error("❌ Role 'leading teacher' does not exist!");
return;
}

// Insert Data
$count = 0;
foreach ($teachers as $teacherData) {
// Create or update user
$user = User::updateOrCreate(
['email' => $teacherData['email']], // Ensure uniqueness by email
[
'firstname' => $teacherData['firstname'] ?? '',
'lastname' => $teacherData['lastname'] ?? '',
'email' => $teacherData['email'],
'country_iso' => $teacherData['country_iso'] ?? null,
'twitter' => $teacherData['twitter'] ?? null,
'website' => $teacherData['website'] ?? null,
'bio' => $teacherData['bio'] ?? null,
'avatar_path' => $teacherData['avatar_path'] ?? '/images/default-avatar.png',
'city_id' => $teacherData['city_id'] ?? null,
'email_verified_at' => $teacherData['email_verified_at'] ?? now(),
]
);

// Assign role if not already assigned
if (!$user->hasRole('leading teacher')) {
$user->assignRole($role);
}

$count++;
}

$this->command->info("✅ Imported $count leading teachers successfully!");
}
}
Loading
Loading