Package Data | |
---|---|
Maintainer Username: | miladimos |
Maintainer Contact: | miladimos@outlook.com (miladimos) |
Package Create Date: | 2021-08-23 |
Package Last Update: | 2023-10-21 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-12 15:00:37 |
Package Statistics | |
---|---|
Total Downloads: | 23 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
A package for attachment files to models
composer require laravelir/attachmentable
Laravelir\Attachmentable\Providers\AttachmentableServiceProvider::class,
php artisan attachmentable:install
First add Attachmentable
trait to models that you want have attachments
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravelir\Attachmentable\Traits\Attachmentable;
class Post extends Model
{
use HasFactory,
Attachmentable;
}
in controllers you have these methods:
namespace App\Http\Controllers;
use App\Models\Post;
class PostController extends Controller
{
public function index()
{
$post = Post::find(1);
$post->attachments // return all attachments
}
}