1. Go to this page and download the library: Download wn/lumen-generators 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/ */
wn / lumen-generators example snippets
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('Wn\Generators\CommandsServiceProvider');
}
}
namespace App;
use Illuminate\Database\Eloquent\Model;
class Task extends Model {
protected $fillable = ["name", "project_id"];
protected $dates = ["due"];
public static $rules = [
"name" => "
namespace App\Http\Controllers;
class TasksController extends Controller {
const MODEL = "App\Task";
use RESTActions;
}
// These lignes will be added
/**
* Routes for resource task
*/
$app->get('task', 'TasksController@all');
$app->get('task/{id}', 'TasksController@get');
$app->post('task', 'TasksController@add');
$app->put('task/{id}', 'TasksController@put');
$app->delete('task/{id}', 'TasksController@remove');
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksMigration extends Migration
{
public function up()
{
Schema::create('tasks', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('project_id')->unsigned();
$table->date('due');
$table->foreign('project_id')
->references('id')
->on('projects');
$table->timestamps();
});
}
public function down()
{
Schema::drop('tasks');
}
}
namespace App;
use Illuminate\Database\Eloquent\Model;
class Task extends Model {
protected $fillable = [];
protected $dates = [];
public static $rules = [
// Validation rules
];
// Relationships
}
//...
public function accounts()
{
return $this->hasMany("Tests\Tmp\Account");
}
public function owner()
{
return $this->belongsTo("App\User");
}
public function number()
{
return $this->hasOne("Tests\Tmp\Phone");
}
public function tags()
{
return $this->belongsToMany("Tests\Tmp\Tag")->withTimestamps();
}
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksMigration extends Migration
{
public function up()
{
Schema::create('tasks', function(Blueprint $table) {
$table->increments('id');
$table->decimal('amount', 5, 2)->after('size')->default(8);
$table->string('title')->nullable();
// Constraints declaration
});
}
public function down()
{
Schema::drop('tasks');
}
}