Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Easily handle files in your Laravel application. No over-engineering allowed.

Notifications You must be signed in to change notification settings

sehrgutesoftware/laravel-attachments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Attachments

Create attachment database column

Create a database field (nullable string) for every attachment of a model, e.g.:

$table->string('profile_image')->nullable();

Define the attachments in your model like this:

protected $image_attachments = [
	'profile_image' => [
	    'path' => 'uploads/user/avatar',
	    'defaults' => [
	        'small' => '.jpg',
	        'medium' => '.jpg',
	        'large' => '.jpg',
	    ],
	    'styles' => [
	        'small' => '100',
	        'medium' => '500',
	        'large' => '1000'
	    ]
	],
	'background_image' => [
	    'path' => 'uploads/user/background',
	    'defaults' => [
	        'small' => '.jpg',
	        'medium' => '.jpg',
	        'large' => '.jpg',
	    ],
	    'styles' => [
	        'small' => '100',
	        'medium' => '500',
	        'large' => '1000'
	    ]
	]
];

Using it

As simple as:

$me->updateImageAttachment('profile_image', $request->fileContent(), $request->fileType());

About

Easily handle files in your Laravel application. No over-engineering allowed.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages