1. Go to this page and download the library: Download tekkenking/documan library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tekkenking / documan example snippets
use Illuminate\Http\Request;
public function store(Request $request)
{
$result = documan('my_disk')
->small()
->thumbnail()
->medium()
->upload($request, 'avatar');
// $result is an array:
// [
// 'fileType' => 'image',
// 'base_name' => 'AbCdEfGhIj.jpg', // ← the original on disk
// 'variations' => [
// 'original' => 'AbCdEfGhIj.jpg', // plain base_name, no prefix
// 'small' => 'small_AbCdEfGhIj.jpg',
// 'thumbnail' => 'thumbnail_AbCdEfGhIj.jpg',
// 'medium' => 'medium_AbCdEfGhIj.jpg',
// ],
// 'links' => [ ... ], // present when returnUploadWith.links = true (default)
// ]
// Save base_name to the database
$user->avatar = $result['base_name'];
$user->save();
}
// Named sizes
$url = documan('my_disk')->show($user->avatar)->medium();
$url = documan('my_disk')->show($user->avatar)->thumbnail();
$url = documan('my_disk')->show($user->avatar)->small();
$url = documan('my_disk')->show($user->avatar)->big();
$url = documan('my_disk')->show($user->avatar)->tiny();
// Original (full-size)
$url = documan('my_disk')->show($user->avatar)->original();
// Custom size (resolves to a variant named 'custom', or any name you supply)
$url = documan('my_disk')->show($user->avatar)->custom('large');
// Return only the filename instead of the full URL
$name = documan('my_disk')->show($user->avatar, true)->medium();
// Hard delete (permanent) — uses the config default
documan('my_disk')->delete($user->avatar);
// Soft delete — override mode at runtime
config(['documan.delete.mode' => 'soft']);
documan('my_disk')->delete($user->avatar);
// Files are moved to: {disk_root}/trash/{filename}
// Delete multiple files at once
documan('my_disk')->delete([$user->avatar, $user->cover_photo]);
// Upload mode: adds a 'custom' size variant
->custom(280, 400)
// Show mode: retrieves the variant named 'large'
->custom('large')
use Tekkenking\Documan\Rules\DocumanFile;
// Allow any Documan-supported type
'file' => ['ict to multiple groups
'report' => ['
use Tekkenking\Documan\DocumanCast;
protected $casts = [
// Basic — disk only
'avatar' => DocumanCast::class.':my_disk',
// With size variants
'avatar' => DocumanCast::class.':my_disk:small|thumbnail|medium',
// Remote disk (resolves URLs against the configured remote host)
'avatar' => DocumanCast::class.':remote_my_disk',
];
// Upload as private for this call only
$result = documan('my_disk')
->visibility('private')
->medium()
->upload($request, 'document');
// Upload as public (explicit, even if config is set to private)
$result = documan('my_disk')
->visibility('public')
->upload($request, 'avatar');