Ibon Azkoitia
Ibon Azkoitia
FFilament
Created by Ibon Azkoitia on 5/15/2024 in #❓┊help
ignoreRecord for TextColumn with different slugs for each domain
Hello! I'm fighting for hours with this and maybe just your experience can help me in minutes. The situation Users should be able to create custom links for different domains. Model 1 = Domain Model 2 = Link (with column for the 'slug') Different domains should be able to have same slug: domain1/slugxyz domain2/slugxyz So I created a custom Rule at that input on the Form.
->rules([
fn (Get $get): Closure => function(string $attribute, mixed $value, Closure $fail) use ($get): bool {
$slugInDomain = Link::where('domain_id', $get('domain_id'))
->where('slug', '=', $value)
->first();

if ( $slugInDomain ) {
$fail("The slug is already in use.");
}

return true;
}
])
->rules([
fn (Get $get): Closure => function(string $attribute, mixed $value, Closure $fail) use ($get): bool {
$slugInDomain = Link::where('domain_id', $get('domain_id'))
->where('slug', '=', $value)
->first();

if ( $slugInDomain ) {
$fail("The slug is already in use.");
}

return true;
}
])
It gets the domain_id from the Select field with the ->live() option. The goal check if a Link for that Domain with that slug exists. If not, continue. If yes, give error The problem: when trying to edit a record, it says it already exists I tried the option ->unique(ignoreRecord: true). But, as i should be able to have same slug for different domains (but just 1 for each domain), i didn't manage to make it work. Thank you!
2 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
Hello everyone, thanks for reading and helping This is a recap of the situation: - I want to create a url shortener platform (for my projects) - Each tenant/project is accesible from the "{originaldomain}/admin/" (shared for all the projects, limited access depending user) - Each tenant/project has a profile field to add a custom domain - Each link I create should have this url structure: {custom_domain}/{string of characters} Shortened url creation process example: - Add {custom_domain} to the Tenant/Project (https:// customdomain .com) - Add final/original url (https:// google .com) - Add the shortened slug (abcd1ef) - Generated url » https:// customdomain .com/abcd1ef - If visit the Generated url = redirected to final/original url (https:// google .com) The problem is that right now, if I do that, it works perfectly and it generates the URL. But, as the {custom_domain} is not mapped to the platform, it gaves an error I know that, as a user in these kind of services like Bitly, you create a CNAME in your {custom_domain} DNSs to their Server IP. But I have no idea how to manage it from the other side, from the creator side. Because if I do that CNAME, the domain gives an error as is not configured in the Platform Thanks for your help!
16 replies