lassehaslev / laravel-image
Installs: 119
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:laravel-plugin
Requires
- lassehaslev/api-response: ^0.1.3
- lassehaslev/image: ^0.2.0
Requires (Dev)
- orchestra/testbench: 3.3.x
- phpunit/phpunit: ^5.6
README
Basic image handeling. Upload, Store in databse, get path, etc.
Install
Run composer require lassehaslev/laravel-image
Create your package and add the following line to providers
in config/app.php
LasseHaslev\LaravelImage\Providers\ServiceProvider::class,
Usage
Run migrations
php artisan migrate
Config
<?php return [ 'owner'=>null, // Set to set a owner object f.eks. 'App\User' 'folder'=>'uploads/images', // Folder to upload to 'routes'=>'/', // Route group name. To prevent setting routes set null ];
Its recomended that you overwrite images::index
view.
To do this add the following to resources/views/vendor/images/index.blade.php
@extends( 'backend' ) @section( 'content' ) @include( 'images::elements.Upload' ) @include( 'images::elements.List' ) @endsection
You can also do the same for images::elements.Upload
and images::elements.List
.
Api
// Upload new image $image = Image::upload( UploadedFile $file ); // Get relative path echo $image->path; // Get full path echo $image->path(); // Get url echo $image->url(); // Delete $image->delete(); // Update/Change image content $image->uploadImage( UploadedFile $file );
Development
# Install dependencies composer install # Install dependencies for automatic tests yarn # Run one time npm run test # Automaticly run test on changes npm run dev