1. Go to this page and download the library: Download escapework/laravelhelpers 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/ */
escapework / laravelhelpers example snippets
use EscapeWork\LaravelHelpers\BaseModel;
class Product extends BaseModel
{
// ...
}
use EscapeWork\LaravelHelpers\BaseModel;
use EscapeWork\LaravelHelpers\SluggableTrait;
class Product extends BaseModel
{
use SluggableTrait;
}
protected $sluggableAttr = 'name';
protected $makeSlugOnUpdate = false;
public function store()
{
$this->product->title = 'Hello World';
$this->product->save();
echo $this->product->slug; // prints hello-world
}
}
// model
...
public function setDateAttribute($date)
{
$this->_setDateAttribute('date', $date, $format = 'd/m/Y');
}
...
// whaterer place you need
$model->date = '10/03/1991'; // this format should be the same as the above
// model
...
public function setPriceBRLAttribute($price)
{
$this->_setCurrencyAttribute('priceBRL', $price);
}
public function setPriceAttribute($price)
{
$this->_setCurrencyAttribute('price', $price, 'USD');
}
...
// whaterer place you need
$model->priceBRL = '10,90';
$model->price = '10.90';
var_dump($model->priceBRL); // (float) 10.90';
var_dump($model->price); // (float) 10.90';
$product = App::make('ProductRepository'); // just a sample, you probably will use dependency injection
$product->findOrFailBy('slug', 'office-chair');
dd($product->title);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.