LasseHaslev / laravel-image by LasseHaslev

119
2
2
Package Data
Maintainer Username: LasseHaslev
Maintainer Contact: lasse@haslev.no (Lasse S. Haslev)
Package Create Date: 2016-12-06
Package Last Update: 2018-03-10
Language: PHP
License: Unknown
Last Refreshed: 2024-11-20 03:02:38
Package Statistics
Total Downloads: 119
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 2
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

lassehaslev/laravel-image

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