namespaces refactoring part 3

This commit is contained in:
Peter Papp
2021-07-19 13:40:26 +02:00
parent 54dc57fcbf
commit 29d1b68dd5
26 changed files with 126 additions and 65 deletions
@@ -74,11 +74,15 @@ class AppFunctionsController extends Controller
*/
public function og_site(Share $shared)
{
$namespace = match ($shared->type) {
'folder' => 'Domain\\Folders\\Models\\Folder',
'file' => 'Domain\\Files\\Models\\File',
};
// Get file/folder record
$item = ('App\\Models\\' . ucfirst($shared->type))
::where('user_id', $shared->user->id)
->where('id', $shared->item_id)
->first();
$item = ($namespace)::where('user_id', $shared->user->id)
->where('id', $shared->item_id)
->first();
if ($item->thumbnail) {
$item->setPublicUrl($shared->token);