Part of the functionality provided by the NovaCkeditor package relies on Larapload, a user-friendly package for managing media and uploads. To fully leverage the capabilities offered by NovaCkeditor, we recommend reading the Larapload first. This will ensure that you can take full advantage of the available abilities and seamlessly integrate media management and uploads into your Laravel Nova application.
Installation
1. Install the package using composer
composer require mostafaznv/nova-ckeditor
2. Publish the configuration, migrations, models, resources, and snippets
3. Prepare the migration, configurations and models
After publishing stubs, essential Image, Video, Audio and File classes will be created in the app/Models and app/Nova/Resources directories respectively. These classes are used for the media-picker in the CKEditor field.
You should create a disk in config/filesystems.php:
If you wish to modify the disk name, remember to update it in the App\Nova\Resources\Image class as well. The third argument of the make function in the ImageUpload field corresponds to the disk name.
If you wish to change the disk name, ensure you rename it in the following places:
With Larupload: In the disk function of the Attachment class located in App\Models\Video
Without Larupload: In the third argument of the make function in the VideoUpload field located in App\Nova\Resources\Video
Larupload utilizes FFMPEG to generate covers from the original video files. By default, Larupload attempts to find the FFMPEG binary path from your system's environment. However, you have the option to define it yourself by publishing the Larupload configuration file. You can use the following command to publish the Larupload configuration file:\
If you wish to modify the disk name, remember to update it in the App\Nova\Resources\Audio class as well. The third argument of the make function in the AudioUpload field corresponds to the disk name.
You should create a disk in config/filesystems.php:
If you wish to modify the disk name, remember to update it in the App\Nova\Resources\File class as well. The third argument of the make function in the FileUpload field corresponds to the disk name.
This feature was introduced in version 7.3.0 of the NovaCKEditor
If you have chosen Laravel's file system, you must make some changes to the migration file. In the migration file, replace the upload column with a string column.
class CreateVideosTable extends Migration
{
public function up()
{
Schema::create('videos', function(Blueprint $table) {
$table->id();
$table->string('name')->index();
// $table->upload('file');
$table->string('file')->index(); // if you prefer not to use Larupload
$table->timestamps();
});
}
}
If you have chosen Laravel's file system, you must make some changes to the model. Remove the Larupload trait and the attachments function from the model.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Video extends Model
{
protected $fillable = ['name', 'file', 'disk'];
protected static function booted(): void
{
parent::booted();
self::saving(function($model) {
$hasLaruploadTrait = method_exists(self::class, 'bootLarupload');
if (!$model->name) {
$name = $hasLaruploadTrait ? $model->file->meta('name') : $model->file;
$model->name = pathinfo($name, PATHINFO_FILENAME);
}
});
}
}
4. Migrate
php artisan migrate
This package utilizes for video handling, allowing you to choose between and Laravel's built-in file system for managing the upload process.
If you have chosen Larupload, there is no need to make any changes to the videos migration file. You can refer to the and documentations for additional configuration options.
If you have chosen Larupload, there is no need to make any changes to the Video model. You can refer to the and documentations for additional configuration options.