Laravel admin form image control source - laravel

In Laravel-admin image control source path is incorrect.
I upload the image to S3 and delete the local image file after that.
But when loading the form, image control is seeking the image in local/media folder.
The reason is 'url' => env('APP_URL').'/media' set like this.
'admin' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/media',
'visibility' => 'public',
I cannot change the url, instead of that somehow I wanna set it here when loading.
$form->image('thumb_path', 'Thumbnail');
Two of below issues are related to this.
https://github.com/z-song/laravel-admin/issues/5118
https://github.com/z-song/laravel-admin/issues/4220
Anybody found a workaround for this or faced the same issue?

What version of laravel are you using in your app

Related

Laravel - Saving Images To New Disk Returns 404 - How To Resolve (Laravel Media Library)

I have multiple disks set up within config/filesystems.php like so: I have recently added 'mealimages'.
'menus' => [
'driver' => 'local',
'root' => storage_path('app/menus'),
'url' => env('APP_URL').'/menu-store',
'visibility' => 'private',
],
'mealimages' => [
'driver' => 'local',
'root' => storage_path('app/meal-images'),
'url' => env('APP_URL').'/meal-images-store',
'visibility' => 'public',
],
I'm using laravel media library to handle my image uploads, in my model, I have configured the collection to use the mealimages disk like:
$this->addMediaCollection('meal-image')->useDisk('mealimages')->singleFile();
I have flushed application cache by running php artisan optimize:clear, tried deleting my /public/storage directory and re-ran php artisan storage:link to try and get the images to show once they have been uploaded. I can confirm that the images are being stored correctly within my storage directly but the URL generated by laravel media library for the image returns 404.
I have also tried updating the visibility but no luck.
I am able to get the functionality and image uploads working correctly and showing if I update the ->useDisk() on the model to use the 'menus' disk.
$this->addMediaCollection('meal-image')->useDisk('menus')->singleFile();
I'm struggling to figure out why its working for the menus disk but not my mealimages disk? What I am missing in order to set up a new filesystem to use?
Any help would be great? Thanks

How to overwrite images via FTP upload in Laravel

I have a third party Laravel project with a function to upload images.
The function generates an operator folder, category sub-folder and product sub-sub-folder with a product image within.
There is no resize option here, so many files are 4MB or more.
I wrote a simple bash script to resize the images and tried to upload them via FTP: now all the files are around 100Kb on the server but in browser inspector I still have 4MB image.
I tried artisan clear:clear and view:clear.
No results.
I even tried to delete one or more images and to rename the entire category folder but browsers are still capable to visualize large images with the same old url. (???)
Cache were cleared on the client side.
The main folder is public/storage/image/
The filesystem.php in config folder says:
return[
'default' => env('FILESYSTEM_DRIVER', 'public'),
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public'
],
]
How can laravel show images when I rename/delete folders and images or (better) what am I missing?

crudbooster, How to change storage path in laravel to public?

I use crudbooster admin generator in laravel 5.4, if I upload a file from a form, it will be stored in own storage directory. Then I should create a symlink to that storage path in public path.
I can't use creating symlinks on my system because of the limitation. How can I upload files directly to public/uploads instead of storage/app/uploads?
I honestly have no clue. Best I can do is point you in the right direction. Crudbooster depends on a package called UniShard/laravel-filemanager. I was looking through the config file for this package and it is similar to the lfm.php in your config folder except there are more options. Perhaps you could use one of these additional options such as base_directory. Not sure how this will work out and it could just be poorly coded.
Original Answer:
You need to create a new disk.
In config\filesystems.php, add this.
'disks' => [
'uploads' => [
'driver' => 'local',
'root' => public_path() . '/uploads'
],
],
Now, when you want to use the storage facade you can just do this:
Storage::disk('uploads');
An example usage:
Storage::disk('uploads')->put('filename', $file_content);
Hope this helps.
we can change it in
vendor/crocodicstudio/crudbooster/src/controllers/cbcontroller.php line: 1010

Upgrading to Laravel 5.2 invalidates all sessions

Upgrading from Laravel 5.1.17 to 5.2. My config/auth.php originally contained:
'driver' => 'eloquent',
'model' => 'Project\User',
'table' => 'users',
New file is the same as the default, except with the updated namespace.
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => Project\User::class,
],
],
My env SESSION_DRIVER is redis. I did not clear anything from Redis. (Note, this also happened in my other projects where driver was file, but I didn't care about it as much for them.)
I have two branches, L5.2 and master (which is on 5.1.17). After switching branches, I simply run composer install
If I login on master, then switch to L5.2, I am logged out
If I switch back to master, I am logged back in
If I login on L5.2, then switch to master, I stay logged in
If I switch back to L5.2, I stay logged in
I'm hesitant to upgrade if it's going to invalidate all of my users' sessions and force them to login again. Is there a way to avoid this?
The only other files that were modified were composer.json, composer.lock, app/Exceptions/Handler.php, and config/app.php; nothing that touched Auth.
I figured out what is causing the session to be invalidated. The problem is the session guard's getName() method.
In 5.1.17:
return 'login_'.md5(get_class($this));
In 5.2 ($this->name would be web by default):
return 'login_'.$this->name.'_'.sha1(get_class($this));
Also, the class name itself changes from Guard to SessionGuard
If I replace this method with:
return 'login_'.md5('Illuminate\Auth\Guard');
That keeps my sessions logged in.
This is progress but not a complete solution yet. The real solution is to update all of your existing sessions with the new name. I'll work on a script to complete this and then update my answer.
That you should do is open app/Http/routes.php
and wrap all your existing routes with:
Route::group(['middleware' => ['web']], function () {
// here your previous routes
});
EDIT
After testing I can confirm this behaviour.
In those cases:
5.1.17 -> 5.2
5.1.23 -> 5.2
5.1.28 -> 5.2.*
after upgrade to 5.2 User seems not be logged anymore. When going in versions in 5.1 branch user stays logged. When going back from 5.2 to 5.1 user is logged again.
At the moment you should probably create issue here https://github.com/laravel/framework/issues and wait for response
EDIT2
It seems it's official and expected behaviour because to upgrade guide has been added:
Because of changes to the authentication system, any existing sessions will be invalidated when you upgrade to Laravel 5.2.

Laravel 5 ElFinder Class replace-this-with-your-middleware does not exist error while browse server

I have configured elfinder in Laravel 5 and also using CKEditor. Everything was fine till until I click on browse server button and then I got "Class replace-this-with-your-middleware does not exist" error.
I have searched the web but I did not find any suitable answer. What can I try next?
You should write your middleware name in elfinder configs.
for example:
'route' => [
'prefix' => 'elfinder',
'middleware' => 'auth'/*replace-this-with-your-middleware*/, //Set to null to disable middleware filter
],
image

Resources