Hik
Hik
Explore posts from servers
FFilament
Created by Hik on 8/16/2024 in #❓┊help
Form Wizard multiple models
is it possible to submit the form in the first step and then submit again in the final step?
7 replies
FFilament
Created by Moh Widodo Nurcahyono on 7/18/2024 in #❓┊help
invoice number in a field
this is if you want to create it after the record is saved in the db. User model:
public static function boot()
{
parent::boot();

self::creating(function ($model) {
// ... code here
});

self::created(function ($model) {
// USER00001
$model->special_identifier = 'USER' . str_pad($model->id, 5, '0', STR_PAD_LEFT);

$model->save(); // You need to save again since this happens after creation
});

self::updating(function ($model) {
// ... code here
});

self::updated(function ($model) {
// ... code here
});

self::deleting(function ($model) {
// ... code here
});

self::deleted(function ($model) {
// ... code here
});
}
public static function boot()
{
parent::boot();

self::creating(function ($model) {
// ... code here
});

self::created(function ($model) {
// USER00001
$model->special_identifier = 'USER' . str_pad($model->id, 5, '0', STR_PAD_LEFT);

$model->save(); // You need to save again since this happens after creation
});

self::updating(function ($model) {
// ... code here
});

self::updated(function ($model) {
// ... code here
});

self::deleting(function ($model) {
// ... code here
});

self::deleted(function ($model) {
// ... code here
});
}
4 replies
FFilament
Created by Hik on 8/16/2024 in #❓┊help
js date time picker time interval
No description
3 replies
FFilament
Created by Hik on 8/16/2024 in #❓┊help
Best option to generate translations
Cool thanks for the reply
4 replies
TTCTheo's Typesafe Cult
Created by Hik on 7/12/2023 in #questions
Sentry Integration
you make an errorFormatter and then you can use that shape in the onError handler whereever you deploy your app:
// packages/api/src/trpc.ts
const t = initTRPC.context<...>().create({
transformer: ...,
errorFormatter: ...,
})

// apps/nextjs/pages/api/trpc/[trpc].ts
export default trpcNext.createNextApiHandler({
onError({ error, shape }) {
if (error.code === 'INTERNAL_SERVER_ERROR') {
shape; // whatever shape you return from the formatter

// send to bug reporting
console.error('Something went wrong', error);
}
},
});
// packages/api/src/trpc.ts
const t = initTRPC.context<...>().create({
transformer: ...,
errorFormatter: ...,
})

// apps/nextjs/pages/api/trpc/[trpc].ts
export default trpcNext.createNextApiHandler({
onError({ error, shape }) {
if (error.code === 'INTERNAL_SERVER_ERROR') {
shape; // whatever shape you return from the formatter

// send to bug reporting
console.error('Something went wrong', error);
}
},
});
alternatively, if you wanna go down the middleware route:
const forwardErrorMiddleware = middleware(async (opts) => {
const result = await opts.next();
if (!result.ok) {
// handle error and send somewhere
// console.log("Error occured in procedure", opts.path);
}
return result;
});

export const publicProcedure = t.procedure.use(forwardErrorMiddleware);
const forwardErrorMiddleware = middleware(async (opts) => {
const result = await opts.next();
if (!result.ok) {
// handle error and send somewhere
// console.log("Error occured in procedure", opts.path);
}
return result;
});

export const publicProcedure = t.procedure.use(forwardErrorMiddleware);
3 replies
TTCTheo's Typesafe Cult
Created by Hik on 7/12/2023 in #questions
Sentry Integration
answer by @marminge moved from ct3a-meta to questions
3 replies