PHP code example of toneflix-code / laravel-fileable
1. Go to this page and download the library: Download toneflix-code/laravel-fileable 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/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use ToneflixCode\LaravelFileable\Traits\Fileable;
class User extends Model
{
use HasFactory, Fileable;
public function registerFileable()
{
$this->fileableLoader([
'avatar' => 'default',
]);
}
}
use ToneflixCode\LaravelFileable\Media;
use App\Models\User;
$user = User::find(1);
$user->image = (new Media())->save('media', "image", $user->image);
$user->saveQuietly();