1. Go to this page and download the library: Download scrnhq/laravel-bakery 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/ */
scrnhq / laravel-bakery example snippets
/**
* The model the schema corresponds to.
*
* @var string
*/
protected $model = \App\Post::class;
namespace App\Support;
use Bakery\Support\Schema as BaseSchema;
class Schema extends BaseSchema
{
/*
* Get the models for the schema.
*
* @return array
*/
public function models()
{
return $this->modelsIn(app_path('Bakery'));
// Or, manually.
return [
App\Bakery\User::class,
App\Bakery\Post::class,
];
}
}
use Bakery\Field;
/**
* Get the fields for the schema.
*
* @return array
*/
public function fields(): array
{
return [
'title' => Field::string(),
];
}
Field::boolean()
Field::float()
Field::ID()
Field::int()
Field::string()
use Bakery\Field;
use App\Bakery\Post;
/**
* Get the fields for the schema.
*
* @return array
*/
public function relations()
{
return [
'posts' => Field::collection(Post::class),
];
}
use Bakery\Field;
use App\Bakery\User;
/**
* Get the fields for the schema.
*
* @return array
*/
public function relations()
{
return [
'user' => Field::model(User::class),
];
}
php artisan bakery:install
php artisan bakery:modelschema Post
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.