Last active
May 26, 2018 13:19
-
-
Save afiqiqmal/4f1a62c12c66d7af68896e8cedfe7d3c to your computer and use it in GitHub Desktop.
Creating custom path in laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function boot() | |
{ | |
... | |
... | |
$this->app->bind('path.tenant', function () use ($tenant) { | |
return "tenant_{$tenant->id}"; | |
}); | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
"autoload": { | |
... | |
"files": ["app/Helpers/helpers.php"] | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
dd(tenant_path()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment