I'm little bit confused, I get Call to undefined method Illuminate\Database\Eloquent\Builder::getAbsolutePath() (View: C:\Users\rust\Desktop\projectName\resources\views\container\index.blade.php)
And my show
method in my ContainerController.php
looks like this :
public function show($args = '')
{
if($document = Document::where('key', $args)->first()) {
return response()->download(storage_path('app'). DIRECTORY_SEPARATOR . $document->getAbsolutePath());
}
$items = explode('/', $args);
$department = Auth::user()->department;
if (Auth::user()->hasRole('Root')) {
$department = Department::where('slug', '=', $items[0])->first();
$items = array_slice($items, 1);
}
if($department == null) {
return redirect('/');
}
if(file_exists(storage_path('app' . DIRECTORY_SEPARATOR . $department->slug . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $items)))
&& !is_dir(storage_path('app' . DIRECTORY_SEPARATOR . $department->slug . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $items)))) {
return response()->file(storage_path('app' . DIRECTORY_SEPARATOR . $department->slug . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $items)));
}
$current_parent = 0;
foreach ($items as $item) {
$container = Container::where('slug', '=', $item)
->where('parent_id', '=', $current_parent)
->where('department_id', '=', $department->id)
->first();
if(!$container) abort(404);
$current_parent = $container->id;
}
$contents = Container::where('parent_id', '=', $current_parent)
->where('department_id', "=", $department->id)
->get();
if (!($container = Container::find($current_parent))) {
$container = $department;
}
return view('container.index', compact('container', 'contents', 'args'));
}
I don't know what I did wrong, but I'm a little bit lost right now