Upload with media manager

Upload with media manager

First, we have to use Imageable trait inside model like:

<?php

namespace App\Models;

use App\Helpers\Imageable;

class Article extends Model
{
    use Imageable,
}

Now take the image input like that: <x-file.image-component data="pass_label" />

Now save image into the database:

$user = User::create([]);
$user->saveImage($request);

Now print the image like: $user->image?->path

Upload without media manager

First, we have to use Profileable trait inside model like:

<?php

namespace App\Models;

use App\Helpers\Profileable;

class Article extends Model
{
    use Profileable,
}

Now take the image input like that: <input type="file" class="form-control" name="image">

Now save image into the database:

$post = Article::create([]);
$post->saveImage($request,300,300); //$request, compress size like 300*300

Now print the image like: storage_asset_path($post->image?->image)