Installation
Requirements
PHP 8.1 or higher
Laravel 9.* or higher
Nova 4
GD or Imagick
FFMPEG (required for larupload usage)
\
Installation
1. Install the package using composer
composer require mostafaznv/nova-ckeditor2. Publish the configuration, migrations, models, resources, and snippets
php artisan vendor:publish --provider="Mostafaznv\NovaCkEditor\FieldServiceProvider"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:
'disks' => [
'image' => [
'driver' => 'local',
'root' => public_path('uploads/image'),
'url' => env('APP_URL') . '/uploads/image',
]
]This package utilizes nova-video for video handling, allowing you to choose between larupload and Laravel's built-in file system for managing the upload process.
Create a disk in config/filesystems.php:
'disks' => [
'video' => [
'driver' => 'local',
'root' => public_path('uploads/video'),
'url' => env('APP_URL') . '/uploads/video',
]
]You should create a disk in config/filesystems.php:
'disks' => [
'audio' => [
'driver' => 'local',
'root' => public_path('uploads/audio'),
'url' => env('APP_URL') . '/uploads/audio',
]
]You should create a disk in config/filesystems.php:
'disks' => [
'file' => [
'driver' => 'local',
'root' => public_path('uploads/file'),
'url' => env('APP_URL') . '/uploads/file',
]
]If you have chosen Larupload, there is no need to make any changes to the videos migration file. You can refer to the nova-video and larupload documentations for additional configuration options.
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 Larupload, there is no need to make any changes to the Video model. You can refer to the nova-video and larupload documentations for additional configuration options.
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 migrateLast updated