Change MYSQL table column type while in relationship

Some times, You will find yourself trapped into a situation where you need to change a column datatype or length, But this column is already used in PK-FK relationship and the solution for this is disable the SET foreign_key_checks = 0; then change the datatype and then re-enable it after you finish the update.

Inline form inputs form groups

Here is a sample form using bootstrap that is being displayed inline

French characters encoding

Some times you will face a problem with french?other language characters in your web page that are not being displayed correctly. Such as instead of apostrophe.. And the solution lies in sing the meta charset='utf-8' in your page header. and also to convert the encoding of this piece of data to utf. Sometimes you might find our this is encoded twice, then you will need to decode it or convert to iso then to utf-8 again. Here are some few suggestions

console.log formData

console.log formData, access formData

Get current route name

If you need to get or check for the current route name or action here is a hint

Integrate Elasticsearch to laravel

Elasticsearch is one of the most commonly used packages for laravel for a better searching capabilities. Here is how to integrate ElasticSearch into your laravel application so that whenever you add/update/delete any record it will be automatically indexed and updated in the elasticsearch index.

Use model names dynamically if you have its name as a string

Sometimes, you will need to use/call models/classes dynamically if you only have its fully qualified name as a string. So for example if you have a record and you got its class|model name using get_class($record), and now you need to access this model using the name you have right now. then you can use the following snippet to do so.

Add Event and Event listener to Laravel

If you need to create an event and its associated event listeners, here are the involved files:

Export PDF from laravel

Incase you want to export HTML content as a PDF file in laravel here is a simple package that you could use:

Send mail in laravel 10

Here is a sample simple code to send email message in laravel