Comments (2)
Hi,
The on-demand filesystem feature on the file manager saves the disk name as default
as your disk wouldn't actually have a name, you need to apply your same business logic when you'll need to retrieve the assets from the disks.
Otherwise you'll need to create those disks in filesystems.php
with specific names and then reuse that name with Storage::disk()
if you want ease of access to the assets.
Regards
Charaf
from nova-file-manager.
You may add a method on your user model which provides the disk instance. So you will be able to configure the filemanager and also retrieve the user's files
<?php
namespace App\Models;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Oneduo\NovaFileManager\Casts\Asset;
class User extends Authenticatable
{
protected $fillable = [
'role',
'slug',
'avatar',
'name',
'email',
'password',
];
protected $casts = [
'avatar' => Asset::class,
];
public function storage(): Filesystem
{
return Storage::build([
'driver' => 'local',
'root' => storage_path("app/public/pouzivatelia/{$this->role}/{$this->slug}"),
'url' => config('app.url')."/storage/pouzivatelia/{$this->role}/{$this->slug}",
]);
}
// this is an example on how to use the custom filesystem
public function avatarExists(): bool
{
if (!$this->avatar) {
return false;
}
return $this->storage()->exists($this->avatar->path);
}
}
You may configure the field like this :
<?php
use Laravel\Nova\Http\Requests\NovaRequest;
use Oneduo\NovaFileManager\FileManager;
class User extends Resource
{
// ...
public function fields(NovaRequest $request): array
{
return [
// ... any other fields
FileManager::make(__('Avatar'), 'avatar')
->filesystem(fn(NovaRequest $request) => $request->user()->storage()),
];
}
}
from nova-file-manager.
Related Issues (20)
- Display label for multiple upload HOT 1
- Incompatibility with ```simple-repeatable``` field HOT 1
- Uncaught (in promise) Error (stuck on loading screen) HOT 1
- Moving files across directories
- Issues with the file manager during record modification. HOT 1
- bug: does not work with GCS Adapter. HOT 2
- You are running an outdated version of the package, a new version is available. even after composer update HOT 7
- Nova flexible content - 404 when fetching media in filemanager HOT 3
- PHP `upload_max_filesize` errors do not display error message HOT 1
- Downloading the files! HOT 1
- Possible new issue with Laravel 10 and latest symfony updates HOT 1
- CKEditor integration HOT 1
- Download private Files HOT 1
- Not able to upload video. HOT 1
- Installation Issue with oneduo/nova-file-manager on Laravel 11 Project HOT 2
- Crop Image is not working after update to v0.12.1 HOT 5
- Run file manager as standalone project HOT 2
- Compatibility Issue whit whitecube/nova-flexible-content HOT 14
- Error 413 when uploading large files HOT 5
- Store Activity Log When User Take action on File Manager HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-file-manager.