PHP code example of agifsofyan / noto

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/ */

    

agifsofyan / noto example snippets


    

        return [
            'model_path' => 'App\Models',
            'file_table' => 'system_files',
            'model_sync' => [
                'User' => 'RainLab\User\Models\User'
            ],
            'extention' => ['jpg', 'jpeg', 'png', 'gif', 'docx', 'xlsx', 'svg', 'pdf']
        ];
    

    

    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()