PHP code example of aminsamadzadeh / vispobish

1. Go to this page and download the library: Download aminsamadzadeh/vispobish 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/ */

    

aminsamadzadeh / vispobish example snippets


...
public function up()
{
	Schema::table('categories', function (Blueprint $table) {
		// vispobish pckage
		$table->string('path')->nullable(); // save path of tree
		$table->unsignedInteger('parent_id')->nullable();
		$table->foreign('parent_id')->references('id')->on('categories');
	});
}
...

...
use Illuminate\Database\Eloquent\Model;
use AminSamadzadeh\Vispobish\Treeable;

class Category extends Model
{
    use Treeable;
}
...

...
public function up()
{
	Schema::table('categories', function (Blueprint $table) {
		$table->string('named_path')->unique(); // just used when set $pahtNamedWith
	});
}
...

...
class Category extends Model
{
    use Treeable;
    public $namedPathWith = 'name';
}
...