-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
515 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
tests/stubs/browsers/2021_08_10_0001_create_authors_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateAuthorsTables extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('authors', function (Blueprint $table) { | ||
createDefaultTableFields($table); | ||
$table->string('title', 200)->nullable(); | ||
$table->text('description')->nullable(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('authors'); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/stubs/browsers/2021_08_10_0002_create_articles_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateArticlesTables extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('articles', function (Blueprint $table) { | ||
createDefaultTableFields($table); | ||
$table->string('title', 200)->nullable(); | ||
$table->text('description')->nullable(); | ||
}); | ||
|
||
Schema::create('article_revisions', function (Blueprint $table) { | ||
createDefaultRevisionsTableFields($table, 'article'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('article_revisions'); | ||
Schema::dropIfExists('articles'); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/stubs/browsers/2021_08_10_0003_create_articles_authors_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateArticleAuthorTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('article_author', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->timestamps(); | ||
$table->integer('position')->unsigned(); | ||
createDefaultRelationshipTableFields($table, 'article', 'author'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('article_author'); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/stubs/browsers/2021_08_10_0004_create_bios_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateBiosTables extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('bios', function (Blueprint $table) { | ||
createDefaultTableFields($table); | ||
$table->string('title', 200)->nullable(); | ||
$table->text('description')->nullable(); | ||
$table->foreignId('author_id')->nullable()->onUpdate('cascade')->onDelete('cascade'); | ||
}); | ||
|
||
Schema::create('bio_revisions', function (Blueprint $table) { | ||
createDefaultRevisionsTableFields($table, 'bio'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('bio_revisions'); | ||
Schema::dropIfExists('bios'); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/stubs/browsers/2021_08_10_0005_create_books_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class CreateBooksTables extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('books', function (Blueprint $table) { | ||
createDefaultTableFields($table); | ||
$table->string('title', 200)->nullable(); | ||
$table->text('description')->nullable(); | ||
}); | ||
|
||
Schema::create('book_revisions', function (Blueprint $table) { | ||
createDefaultRevisionsTableFields($table, 'book'); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('book_revisions'); | ||
Schema::dropIfExists('books'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use A17\Twill\Models\Behaviors\HasRevisions; | ||
use A17\Twill\Models\Model; | ||
|
||
class Article extends Model | ||
{ | ||
use HasRevisions; | ||
|
||
protected $fillable = [ | ||
'published', | ||
'title', | ||
'description', | ||
]; | ||
|
||
public function authors() | ||
{ | ||
return $this->belongsToMany(Author::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use A17\Twill\Http\Controllers\Admin\ModuleController; | ||
|
||
class ArticleController extends ModuleController | ||
{ | ||
protected $moduleName = 'articles'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Repositories; | ||
|
||
use A17\Twill\Repositories\Behaviors\HandleRevisions; | ||
use A17\Twill\Repositories\ModuleRepository; | ||
use App\Models\Article; | ||
|
||
class ArticleRepository extends ModuleRepository | ||
{ | ||
use HandleRevisions; | ||
|
||
public function __construct(Article $model) | ||
{ | ||
$this->model = $model; | ||
} | ||
|
||
public function afterSave($object, $fields) | ||
{ | ||
$this->updateBrowser($object, $fields, 'authors'); | ||
parent::afterSave($object, $fields); | ||
} | ||
|
||
public function getFormFields($object) | ||
{ | ||
$fields = parent::getFormFields($object); | ||
$fields['browsers']['authors'] = $this->getFormFieldsForBrowser($object, 'authors'); | ||
return $fields; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Admin; | ||
|
||
use A17\Twill\Http\Requests\Admin\Request; | ||
|
||
class ArticleRequest extends Request | ||
{ | ||
public function rulesForCreate() | ||
{ | ||
return []; | ||
} | ||
|
||
public function rulesForUpdate() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Models\Revisions; | ||
|
||
use A17\Twill\Models\Revision; | ||
|
||
class ArticleRevision extends Revision | ||
{ | ||
protected $table = "article_revisions"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
|
||
use A17\Twill\Models\Model; | ||
|
||
class Author extends Model | ||
{ | ||
protected $fillable = [ | ||
'published', | ||
'title', | ||
'description', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use A17\Twill\Http\Controllers\Admin\ModuleController; | ||
|
||
class AuthorController extends ModuleController | ||
{ | ||
protected $moduleName = 'authors'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Repositories; | ||
|
||
use A17\Twill\Repositories\ModuleRepository; | ||
use App\Models\Author; | ||
|
||
class AuthorRepository extends ModuleRepository | ||
{ | ||
public function __construct(Author $model) | ||
{ | ||
$this->model = $model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Admin; | ||
|
||
use A17\Twill\Http\Requests\Admin\Request; | ||
|
||
class AuthorRequest extends Request | ||
{ | ||
public function rulesForCreate() | ||
{ | ||
return []; | ||
} | ||
|
||
public function rulesForUpdate() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use A17\Twill\Models\Behaviors\HasRevisions; | ||
use A17\Twill\Models\Model; | ||
|
||
class Bio extends Model | ||
{ | ||
use HasRevisions; | ||
|
||
protected $fillable = [ | ||
'published', | ||
'title', | ||
'description', | ||
'author_id', | ||
]; | ||
|
||
public function author() | ||
{ | ||
return $this->belongsTo(Author::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use A17\Twill\Http\Controllers\Admin\ModuleController; | ||
|
||
class BioController extends ModuleController | ||
{ | ||
protected $moduleName = 'bios'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Repositories; | ||
|
||
use A17\Twill\Repositories\Behaviors\HandleRevisions; | ||
use A17\Twill\Repositories\ModuleRepository; | ||
use App\Models\Bio; | ||
|
||
class BioRepository extends ModuleRepository | ||
{ | ||
use HandleRevisions; | ||
|
||
protected $browsers = ['author']; | ||
|
||
public function __construct(Bio $model) | ||
{ | ||
$this->model = $model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Admin; | ||
|
||
use A17\Twill\Http\Requests\Admin\Request; | ||
|
||
class BioRequest extends Request | ||
{ | ||
public function rulesForCreate() | ||
{ | ||
return []; | ||
} | ||
|
||
public function rulesForUpdate() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Models\Revisions; | ||
|
||
use A17\Twill\Models\Revision; | ||
|
||
class BioRevision extends Revision | ||
{ | ||
protected $table = "bio_revisions"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use A17\Twill\Models\Behaviors\HasRevisions; | ||
use A17\Twill\Models\Behaviors\HasRelated; | ||
use A17\Twill\Models\Model; | ||
|
||
class Book extends Model | ||
{ | ||
use HasRevisions, HasRelated; | ||
|
||
protected $fillable = [ | ||
'published', | ||
'title', | ||
'description', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use A17\Twill\Http\Controllers\Admin\ModuleController; | ||
|
||
class BookController extends ModuleController | ||
{ | ||
protected $moduleName = 'books'; | ||
} |
Oops, something went wrong.