Skip to content

Instantly share code, notes, and snippets.

@jeffhappens
jeffhappens / add_possessive
Last active January 13, 2022 03:44
Laravel Helper function that converts a string to a possessive
<?php
// Add this function to app/helpers.php
if ( ! function_exists('str_possessive')) {
/**
* Make a string possessive.
* @param string $string
* @return string
*/
function str_possessive($string) {
return $string.'\''.($string[strlen($string) - 1] != 's' ? 's' : '');