This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

rajakhoury
rajakhoury

Hi, Any idea why this error is happening ? Here's the invoice model

Error : Class twig.string does not exist D:\xampp\htdocs\test\pos\vendor\laravel\framework\src\Illuminate\Container\Container.php line 741

use App;
use File;
use Model;
use October\Rain\Mail\MailParser;
use October\Rain\Parse\Syntax\SyntaxModelTrait;
use October\Rain\Parse\Syntax\Parser;

/**
 * InvoiceStatus Model
 */
class InvoiceTemplate extends Model
{

    use SyntaxModelTrait;

    /**
     * @var string The database table used by the model.
     */
    public $table = 'cashier_invoice_templates';
    /**
     * @var array Guarded fields
     */
    protected $guarded = [];
    /**
     * @var array Fillable fields
     */
    protected $fillable = [];
    /**
     * @var array List of attribute names which are json encoded and decoded from the database.
     */
    protected $jsonable = ['syntax_data', 'syntax_fields'];
    public $timestamps = false;
    public function getContentCssAttribute($content)
    {
        if (!$this->exists || !strlen($content))
            return File::get(__DIR__ . '/invoicetemplate/default_content.css');
        return $content;
    }
    public function getContentHtmlAttribute($content)
    {
        if (!$this->exists || !strlen($content))
            return File::get(__DIR__ . '/invoicetemplate/default_content.htm');
        return $content;
    }
    public function beforeSave()
    {
        $this->makeSyntaxFields($this->content_html);
    }
    public function renderInvoice($invoice)
    {
        $twig = App::make('twig.string');
        $parser = $this->getSyntaxParser($this->content_html);
        $invoiceData = $this->getSyntaxData();
        $invoiceTemplate = $parser->render($invoiceData);
        $twigData = [
            'invoice' => $invoice,
            'css' => $this->content_css
        ];
        $twigTemplate = $twig->render($invoiceTemplate, $twigData);
        return $twigTemplate;
    }
}

Last updated

daftspunky
daftspunky

Looks like this code was borrowed from the Pay plugin and hasn't been maintained.

rajakhoury
rajakhoury

Hi, actually it's the OC-Cashier plugin from Alxy https://github.com/alxy/oc-cashier-plugin - The InvoiceTemplate Model.

I posted on github the issue. Any idea ? Thank you

Last updated

Vojta Svoboda
Vojta Svoboda

I have sent pull request with fix

rajakhoury
rajakhoury

Thanks!

public function renderInvoice($invoice)
    {
        $parser = $this->getSyntaxParser($this->content_html);
        $invoiceData = $this->getSyntaxData();
        $invoiceTemplate = $parser->render($invoiceData);
        $twigData = [
            'invoice' => $invoice,
            'css' => $this->content_css
        ];
        $twigTemplate = Twig::parse($invoiceTemplate, $twigData);
        return $twigTemplate;
    }

Solved the problem..

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.