Giter Club home page Giter Club logo

laraberg-nova's Introduction

Laraberg Nova

A nova field for Laraberg

Installation

Install via composer

composer require van-ons/laraberg-nova

Publish Laraberg files

php artisan vendor:publish --provider="VanOns\Laraberg\LarabergServiceProvider"

Laraberg provides a CSS file that should be present on the page you want to render content on:

<link rel="stylesheet" href="{{asset('vendor/laraberg/css/laraberg.css')}}">

Usage

Simply register the field in your Resource

LarabergNova::make(__('Content'), 'content')

Add the RendersContent trait to your model. And optionally define the $contentColumn property to point to the column that holds your Laraberg content, this defaults to content.

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use VanOns\Laraberg\Traits\RendersContent;

class Post extends Model
{
    use HasFactory, RendersContent;
    
    protected $contentColumn = 'content';
       
    ...
}

Call the render method on your model in a template.

{!! $model->render() !!}

Options

The field has a few options you can configure.

Height

You can customize the height of the editor.

LarabergNova::make(__('Content'), 'content')->height(600)

Attachments

You can enable uploading attachments.

LarabergNova::make(__('Content'), 'content')->withFiles('public')

You will need to add the following migration to make this work.

Schema::create('laraberg_nova_pending_attachments', function (Blueprint $table) {
    $table->increments('id');
    $table->string('draft_id')->index();
    $table->string('attachment');
    $table->string('disk');
    $table->timestamps();
});

Schema::create('laraberg_nova_attachments', function (Blueprint $table) {
    $table->increments('id');
    $table->string('attachable_type');
    $table->unsignedInteger('attachable_id');
    $table->string('attachment');
    $table->string('disk');
    $table->string('url')->index();
    $table->timestamps();
    $table->index(['attachable_type', 'attachable_id']);
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.