feat: implement barangay system phases 2-14
Complete adaptation from BukidBountyApp to Philippine barangay governance: - Barangay models: Resident, Household, HouseholdMember, Blotter, BlotterHearing, DocumentRequest, RequestPayment, RequestType, BarangayProject, BarangayBudget - Controllers: ResidentController, HouseholdController, BlotterController, BlotterHearingController, DocumentRequestController, RequestTypeController, ProjectController, BudgetController, QRPHController, AdminConsoleController, UserController, FileController, ChapterController, LoginController - Vue pages: Home, ManageResidents, ResidentProfile, ManageHouseholds, ManageBlotters, BlotterDetail, RequestDocument, ManageDocumentRequests, DocumentRequestDetail, ManageRequestTypes, ManageProjects, BudgetLedger, AdminConsole - Barangay roles: PunongBarangay, Kagawad, Secretary, Treasurer, SK, Tanod, BHW, Staff, Resident - UserPermissions matrix rewritten with barangay-specific permission mappings - VueRouteMap replaced with barangay SPA routes - UserActions enum references corrected across all controllers - Removed all market/cooperative/POS/subscription code and models
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Market\UserInfo;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Command\Command as SymfonyCommand;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @Command
|
||||
*/
|
||||
class ImportReadmeMemberData extends SymfonyCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('import:readme-member');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('Import member data from README.md for Rex Moran Loba');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$email = 'rexm.loba@gmail.com';
|
||||
$user = User::where('email', $email)->first();
|
||||
|
||||
if (!$user) {
|
||||
$this->output->info("User with email {$email} not found. Creating...");
|
||||
$user = User::create([
|
||||
'name' => 'Rex Moran Loba',
|
||||
'fullname' => 'Rex Moran Loba',
|
||||
'email' => $email,
|
||||
'username' => 'rexmloba',
|
||||
'password' => password_hash('password', PASSWORD_DEFAULT),
|
||||
'hashkey' => bin2hex(random_bytes(16)),
|
||||
'active' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
$userInfo = $user->userInfo;
|
||||
if (!$userInfo) {
|
||||
$userInfo = new UserInfo(['user_id' => $user->id]);
|
||||
$userInfo->hashkey = bin2hex(random_bytes(16));
|
||||
}
|
||||
|
||||
$userInfo->firstname = 'Rex Moran';
|
||||
$userInfo->lastname = 'Loba';
|
||||
$userInfo->email = $email;
|
||||
$userInfo->is_active = true;
|
||||
|
||||
// Example address data based on feedback
|
||||
$userInfo->addresses = [
|
||||
[
|
||||
'house_no' => 'Unit 1234',
|
||||
'street' => 'Street Name',
|
||||
'barangay' => 'Barangay Name',
|
||||
'city' => 'City Name',
|
||||
'province' => 'Province Name',
|
||||
'region' => 'Region Name',
|
||||
'country' => 'Philippines',
|
||||
'zipcode' => '1234'
|
||||
]
|
||||
];
|
||||
|
||||
if ($userInfo->save()) {
|
||||
$this->output->success("Profile for Rex Moran Loba updated successfully.");
|
||||
} else {
|
||||
$this->output->error("Failed to update profile.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Market\Product;
|
||||
use App\Models\Market\Store;
|
||||
use App\Models\User;
|
||||
use Hypervel\Console\Command;
|
||||
use Hypervel\Support\Facades\Auth;
|
||||
|
||||
class SeedDemoProducts extends Command
|
||||
{
|
||||
protected ?string $signature = 'demo:seed-products {store_hash : The hashkey of the target store}';
|
||||
|
||||
protected string $description = 'Seed demo agricultural products';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$storeHash = $this->argument('store_hash');
|
||||
|
||||
$store = Store::where('hashkey', $storeHash)->first();
|
||||
if (! $store) {
|
||||
$this->error('Store not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$ultimateUser = User::where('acct_type', 'ULTIMATE')->first();
|
||||
if (! $ultimateUser) {
|
||||
$this->error('No ULTIMATE user found.');
|
||||
return;
|
||||
}
|
||||
|
||||
Auth::loginUsingId($ultimateUser->id);
|
||||
|
||||
$products = [
|
||||
['name' => 'Organic White Rice (25kg sack)', 'category' => 'Grains & Cereals', 'subcategory' => 'Rice', 'price' => 1200, 'unit' => 'sack', 'available' => 100],
|
||||
['name' => 'Organic Brown Rice (5kg)', 'category' => 'Grains & Cereals', 'subcategory' => 'Rice', 'price' => 280, 'unit' => 'kg', 'available' => 200],
|
||||
['name' => 'White Corn Grits', 'category' => 'Grains & Cereals', 'subcategory' => 'Corn', 'price' => 85, 'unit' => 'kg', 'available' => 300],
|
||||
['name' => 'Yellow Corn (fresh ears)', 'category' => 'Grains & Cereals', 'subcategory' => 'Corn', 'price' => 35, 'unit' => 'piece', 'available' => 500],
|
||||
['name' => 'Fresh Kangkong (Water Spinach)', 'category' => 'Fresh Produce', 'subcategory' => 'Leafy Vegetables', 'price' => 25, 'unit' => 'bundle', 'available' => 150],
|
||||
['name' => 'Pechay (Bok Choy)', 'category' => 'Fresh Produce', 'subcategory' => 'Leafy Vegetables', 'price' => 30, 'unit' => 'bundle', 'available' => 150],
|
||||
['name' => 'Ampalaya (Bitter Gourd)', 'category' => 'Fresh Produce', 'subcategory' => 'Vegetables', 'price' => 60, 'unit' => 'kg', 'available' => 100],
|
||||
['name' => 'Sitaw (String Beans)', 'category' => 'Fresh Produce', 'subcategory' => 'Vegetables', 'price' => 55, 'unit' => 'bundle', 'available' => 120],
|
||||
['name' => 'Kamote (Sweet Potato)', 'category' => 'Fresh Produce', 'subcategory' => 'Root Crops', 'price' => 40, 'unit' => 'kg', 'available' => 200],
|
||||
['name' => 'Gabi (Taro Root)', 'category' => 'Fresh Produce', 'subcategory' => 'Root Crops', 'price' => 50, 'unit' => 'kg', 'available' => 150],
|
||||
['name' => 'Sayote (Chayote)', 'category' => 'Fresh Produce', 'subcategory' => 'Vegetables', 'price' => 45, 'unit' => 'kg', 'available' => 180],
|
||||
['name' => 'Labanos (Radish)', 'category' => 'Fresh Produce', 'subcategory' => 'Root Crops', 'price' => 30, 'unit' => 'bundle', 'available' => 100],
|
||||
['name' => 'Fresh Tomatoes', 'category' => 'Fresh Produce', 'subcategory' => 'Vegetables', 'price' => 70, 'unit' => 'kg', 'available' => 200],
|
||||
['name' => 'Carabao Mango (green)', 'category' => 'Fresh Produce', 'subcategory' => 'Fruits', 'price' => 90, 'unit' => 'kg', 'available' => 100],
|
||||
['name' => 'Banana (Latundan)', 'category' => 'Fresh Produce', 'subcategory' => 'Fruits', 'price' => 65, 'unit' => 'hand', 'available' => 80],
|
||||
['name' => 'Pineapple (Bukidnon)', 'category' => 'Fresh Produce', 'subcategory' => 'Fruits', 'price' => 80, 'unit' => 'piece', 'available' => 60],
|
||||
['name' => 'Native Chicken (live)', 'category' => 'Livestock & Poultry', 'subcategory' => 'Poultry', 'price' => 350, 'unit' => 'piece', 'available' => 30],
|
||||
['name' => 'Free-range Eggs', 'category' => 'Livestock & Poultry', 'subcategory' => 'Eggs', 'price' => 12, 'unit' => 'piece', 'available' => 500],
|
||||
['name' => 'Fresh Tilapia', 'category' => 'Seafood', 'subcategory' => 'Freshwater Fish', 'price' => 130, 'unit' => 'kg', 'available' => 50],
|
||||
['name' => 'Bangus (Milkfish)', 'category' => 'Seafood', 'subcategory' => 'Saltwater Fish', 'price' => 180, 'unit' => 'kg', 'available' => 50],
|
||||
['name' => 'Carabao Milk (1L)', 'category' => 'Processed Goods', 'subcategory' => 'Dairy', 'price' => 120, 'unit' => 'liter', 'available' => 60],
|
||||
['name' => 'Coconut Oil (Virgin, 1L)', 'category' => 'Processed Goods', 'subcategory' => 'Oils', 'price' => 250, 'unit' => 'bottle', 'available' => 40],
|
||||
['name' => 'Organic Peanuts (roasted)', 'category' => 'Processed Goods', 'subcategory' => 'Nuts', 'price' => 95, 'unit' => '250g pack', 'available' => 80],
|
||||
['name' => 'Muscovado Sugar', 'category' => 'Processed Goods', 'subcategory' => 'Sweeteners', 'price' => 110, 'unit' => '250g pack', 'available' => 60],
|
||||
['name' => 'Fresh Turmeric (Luyang Dilaw)', 'category' => 'Fresh Produce', 'subcategory' => 'Herbs & Spices', 'price' => 60, 'unit' => '100g pack', 'available' => 100],
|
||||
];
|
||||
|
||||
$created = [];
|
||||
|
||||
foreach ($products as $item) {
|
||||
$product = new Product();
|
||||
$product->name = $item['name'];
|
||||
$product->category = $item['category'];
|
||||
$product->subcategory = $item['subcategory'];
|
||||
$product->price = $item['price'];
|
||||
$product->unitname = $item['unit'];
|
||||
$product->description = $item['name'];
|
||||
$product->is_active = true;
|
||||
$product->save();
|
||||
|
||||
$store->products()->attach($product->id, [
|
||||
'price' => $item['price'],
|
||||
'available' => $item['available'],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$created[] = $product;
|
||||
}
|
||||
|
||||
$count = count($created);
|
||||
$this->info("Created {$count} products and attached to store {$store->name}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user