Skip to content

Instantly share code, notes, and snippets.

@afiqiqmal
Last active May 26, 2018 13:19
Show Gist options
  • Save afiqiqmal/4f1a62c12c66d7af68896e8cedfe7d3c to your computer and use it in GitHub Desktop.
Save afiqiqmal/4f1a62c12c66d7af68896e8cedfe7d3c to your computer and use it in GitHub Desktop.
Creating custom path in laravel
public function boot()
{
...
...
$this->app->bind('path.tenant', function () use ($tenant) {
return "tenant_{$tenant->id}";
});
...
}
...
"autoload": {
...
"files": ["app/Helpers/helpers.php"]
},
<?php
if (! function_exists('tenant_path')) {
/**
* Get the path to the tenant folder.
*
* @param string $path
* @return string
*/
function tenant_path($path = '')
{
return ""; //also not working
return app()->make('path.tenant').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path);
}
}
<?php
...
dd(tenant_path())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment