PHP code example of novius / laravel-nova-visual-composer
1. Go to this page and download the library: Download novius/laravel-nova-visual-composer 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/ */
novius / laravel-nova-visual-composer example snippets
protected function schedule(Schedule $schedule)
{
$schedule->command('nova-visual-composer:purge-tmp-files')
->daily();
}
$table->longText('content')->nullable();
use Illuminate\Database\Eloquent\Model;
class Foo extends Model {
protected $casts = [
'content' => 'object',
];
}
use App\Nova\Resource;
use Novius\NovaVisualComposer\NovaVisualComposer;
class FooResource extends Resource
{
public function fields(Request $request)
{
return [
// ..
NovaVisualComposer::make('Content')
->stacked(),
// ..
];
}
}
@foreach($item->content as $row)
{!! $row->template::renderFront($row->content) !!}
@endforeach
namespace App\Nova\Templates\Rows;
use Novius\NovaVisualComposer\Templates\RowTemplateAbstract;
use Novius\NovaVisualComposer\Traits\HasImageField;
use Novius\NovaVisualComposer\Traits\HasPrunableFiles;
class ImageText extends RowTemplateAbstract
{
use HasImageField;
use HasPrunableFiles;
public static $name = 'image-text';
protected static function imageFieldsIndexes(): array
{
return [0]; // Because image field is the first field that contains "js-visual-field" class of CRUD view
}
}