PHP code example of asseco-voice / laravel-attachments

1. Go to this page and download the library: Download asseco-voice/laravel-attachments 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/ */

    

asseco-voice / laravel-attachments example snippets


use Asseco\Attachments\App\Traits\Attachable;

class Product extends Model
{
    use Attachable;
    
    // ...   
}

Route::post('models/{model}/attachments', [ModelAttachmentController::class, 'store']);

public function store(Request $request, Model $model): JsonResponse
{
    $ids = Arr::get($request->validated(), 'attachment_ids', []);

    $model->attachments()->sync($ids);

    return response()->json('success');
}