1. Go to this page and download the library: Download agifsofyan/noto 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 Agifsofyan\Noto\Traits\NotoMorph;
class User
{
use NotoMorph;
public function avatar()
{
return $this->morphOneNoto('avatar');
}
public function avatars()
{
return $this->morphManyNoto('avatars');
}
$user->create($data); // To create new data
or
$user->save(); // To create new data or update the data
$field = 'avatar';
$fields = 'avatars';
if($request->hasFile($field) && $request->file($field)->isValid()){
$user->saveOneFile($request->file($field), $field, $user->id);
}
if($request->hasFile($fields) && $request->file($fields)->isValid()){
$user->saveManyFile($request->file($fields), $fields, $user->id);
}
$user?->avatar()?->getThumb(150, 150)
$user?->avatar()?->getPath()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.