reinterpret_cast<int*>(ptr) = -1
reinterpret_cast<int*>(ptr) = -1
Explore posts from servers
FFilament
Created by reinterpret_cast<int*>(ptr) = -1 on 6/16/2024 in #❓┊help
send an email after creating a record
as title says , i want to send an email after creating a record , for example after creating a user via filament admin panel i want to notify the user via email about his new account ( simple example and similar to what i need )
9 replies
PPrisma
Created by reinterpret_cast<int*>(ptr) = -1 on 5/22/2024 in #help-and-questions
user not saving on mongodb but works fine with mysql
hi , i was using mysql and switched to test mongodb , followed the docs on mongodb and my User model looks as follow now :
enum Role {
USER
MOD
ADMIN
}

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
password String
subscriptionNumber String?
firstName String
lastName String
phone String?
isAccepted Boolean @default(false)
role Role
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum Role {
USER
MOD
ADMIN
}

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
password String
subscriptionNumber String?
firstName String
lastName String
phone String?
isAccepted Boolean @default(false)
role Role
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
and this is my controller ( using express and ts ):
export const registerUser = async (req: Request, res: Response) => {
const { email, password, firstName, lastName, role, phone } = req.body;

try {
const salt = await bcrypt.genSalt(10);
const photo = req.file ? req.file.filename : 'default.jpg';
const userData: any = {
email: email,
password: await bcrypt.hash(password, salt),
firstName: firstName,
lastName: lastName,
role: role,
photo: photo,
phone: phone,
};

const user = await prisma.user.create({
data: userData,
});
console.log(user);
res.json(ok('NEW_USER_ADDED'));
} catch (err: any) {
if (err instanceof Prisma.PrismaClientKnownRequestError) {
if (err.code === 'P2002') {
res.status(400).json(error('EMAIL_IN_USE'));
}
}
return `${err.message}`;
}
};
export const registerUser = async (req: Request, res: Response) => {
const { email, password, firstName, lastName, role, phone } = req.body;

try {
const salt = await bcrypt.genSalt(10);
const photo = req.file ? req.file.filename : 'default.jpg';
const userData: any = {
email: email,
password: await bcrypt.hash(password, salt),
firstName: firstName,
lastName: lastName,
role: role,
photo: photo,
phone: phone,
};

const user = await prisma.user.create({
data: userData,
});
console.log(user);
res.json(ok('NEW_USER_ADDED'));
} catch (err: any) {
if (err instanceof Prisma.PrismaClientKnownRequestError) {
if (err.code === 'P2002') {
res.status(400).json(error('EMAIL_IN_USE'));
}
}
return `${err.message}`;
}
};
i'm sure the code is fine but still i have no idea what's going on wrong in here , i did push and generate my prisma and i see the tables fine in my mongodb compass any help is appreciated
4 replies
FFilament
Created by reinterpret_cast<int*>(ptr) = -1 on 10/24/2023 in #❓┊help
show hidden fields conditionaly not working
as title says
Forms\Components\Checkbox::make('availability')->default(true),
Forms\Components\DatePicker::make('from')->hidden(fn(Get $get)=> $get('availability') === false),
Forms\Components\DatePicker::make('to')->hidden(fn(Get $get)=> $get('availability') === false),
Forms\Components\Checkbox::make('availability')->default(true),
Forms\Components\DatePicker::make('from')->hidden(fn(Get $get)=> $get('availability') === false),
Forms\Components\DatePicker::make('to')->hidden(fn(Get $get)=> $get('availability') === false),
4 replies
TtRPC
Created by reinterpret_cast<int*>(ptr) = -1 on 10/21/2023 in #❓-help
Attempted import error: 'hashQueryKey' is not exported from '@tanstack/react-query' issue
i'm getting this error while trying trpc with latest next version , i tried downgrading but got another error Error: (0 , react__WEBPACK_IMPORTED_MODULE_3__.createContext) is not a function
2 replies
FFilament
Created by reinterpret_cast<int*>(ptr) = -1 on 9/14/2023 in #❓┊help
draggable content
guys i want to create draggable content to be reordered in my crud , is there a way to achieve this? , like i want to display my categories as a tree ( see image ) to be reordered and save all the id's of categories that are available in the tree ( can delete only the image is just to show what i want to achieve ) any help is appreciated
3 replies
FFilament
Created by reinterpret_cast<int*>(ptr) = -1 on 9/10/2023 in #❓┊help
how to save user_id on create and limit records per user
as the title says , i want to save current logged in user_id when i save a form that will associated with the user and how to limit user to create one only record , for example a user will create a business profile , i want him to be only able to create only one business profile not as many as he wants
15 replies