function parse_resource_links($text) { $str = preg_replace_callback('/(\\w+):(\\d+)/i', function ($matches) { $resource = strtolower(str_plural($matches[1], 2)); $id = $matches[2]; $label = ucfirst($matches[1]) . ' #' . $id; if ($resource == 'customers') { $customer = \NodenDb\Customers::find($id); $label = $customer->full_name; } return '<a href="/' . $resource . '/' . $id . '">' . $label . '</a>'; }, $text); return $str; }
public function guitars($id) { $customer = Customers::findOrFail($id); return \Response::json($customer->guitars); }