Skip to content

Commit

Permalink
Change templates and stubs to use tabs - closes #281
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Mar 13, 2014
1 parent ee77a12 commit b3c2974
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 70 deletions.
4 changes: 2 additions & 2 deletions src/Way/Generators/templates/migration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class $CLASS$ extends Migration {
*/
public function up()
{
$UP$
$UP$
}


Expand All @@ -23,7 +23,7 @@ class $CLASS$ extends Migration {
*/
public function down()
{
$DOWN$
$DOWN$
}

}
2 changes: 1 addition & 1 deletion src/Way/Generators/templates/model.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

class $NAME$ extends \Eloquent {
protected $fillable = [];
protected $fillable = [];
}
32 changes: 16 additions & 16 deletions src/Way/Generators/templates/scaffolding/controller.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class $NAME$ extends \BaseController {
*/
public function index()
{
$$COLLECTION$ = $MODEL$::all();
$$COLLECTION$ = $MODEL$::all();

return View::make('$COLLECTION$.index', compact('$COLLECTION$'));
return View::make('$COLLECTION$.index', compact('$COLLECTION$'));
}

/**
Expand All @@ -21,7 +21,7 @@ class $NAME$ extends \BaseController {
*/
public function create()
{
return View::make('$COLLECTION$.create');
return View::make('$COLLECTION$.create');
}

/**
Expand All @@ -31,16 +31,16 @@ class $NAME$ extends \BaseController {
*/
public function store()
{
$validator = Validator::make($data = Input::all(), $MODEL$::$rules);
$validator = Validator::make($data = Input::all(), $MODEL$::$rules);

if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}
if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}

$MODEL$::create($data);
$MODEL$::create($data);

return Redirect::route('$COLLECTION$.index');
return Redirect::route('$COLLECTION$.index');
}

/**
Expand All @@ -51,9 +51,9 @@ class $NAME$ extends \BaseController {
*/
public function show($id)
{
$$RESOURCE$ = $MODEL$::findOrFail($id);
$$RESOURCE$ = $MODEL$::findOrFail($id);

return View::make('$COLLECTION$.show', compact('$RESOURCE$'));
return View::make('$COLLECTION$.show', compact('$RESOURCE$'));
}

/**
Expand Down Expand Up @@ -81,10 +81,10 @@ class $NAME$ extends \BaseController {

$validator = Validator::make($data = Input::all(), $MODEL$::$rules);

if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}
if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}

$$RESOURCE$->update($data);

Expand Down
12 changes: 6 additions & 6 deletions src/Way/Generators/templates/scaffolding/model.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

class $NAME$ extends \Eloquent {

// Add your validation rules here
public static $rules = [
// 'title' => 'required'
];
// Add your validation rules here
public static $rules = [
// 'title' => 'required'
];

// Don't forget to fill this array
protected $fillable = [];
// Don't forget to fill this array
protected $fillable = [];

}
4 changes: 2 additions & 2 deletions src/Way/Generators/templates/schema.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Schema::$METHOD$('$TABLE$', function(Blueprint $table) {
$FIELDS$
});
$FIELDS$
});
18 changes: 9 additions & 9 deletions src/Way/Generators/templates/seed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use Faker\Factory as Faker;

class $CLASS$ extends Seeder {

public function run()
{
$faker = Faker::create();
public function run()
{
$faker = Faker::create();

foreach(range(1, 10) as $index)
{
$MODEL$::create([
foreach(range(1, 10) as $index)
{
$MODEL$::create([

]);
}
}
]);
}
}

}
12 changes: 6 additions & 6 deletions tests/stubs/AddTitleToOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class AddTitleToOrdersTable extends Migration {
*/
public function up()
{
Schema::table('orders', function(Blueprint $table) {
$table->string('title');
});
Schema::table('orders', function(Blueprint $table) {
$table->string('title');
});
}


Expand All @@ -25,9 +25,9 @@ class AddTitleToOrdersTable extends Migration {
*/
public function down()
{
Schema::table('orders', function(Blueprint $table) {
$table->dropColumn('title');
});
Schema::table('orders', function(Blueprint $table) {
$table->dropColumn('title');
});
}

}
8 changes: 4 additions & 4 deletions tests/stubs/CreateComplexOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class CreateOrdersTable extends Migration {
*/
public function up()
{
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
$table->string('title', 50)->unique();
$table->text('body')->unique()->nullable();
$table->timestamps();
});
});
}


Expand All @@ -28,7 +28,7 @@ class CreateOrdersTable extends Migration {
*/
public function down()
{
Schema::drop('orders');
Schema::drop('orders');
}

}
8 changes: 4 additions & 4 deletions tests/stubs/CreateOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class CreateOrdersTable extends Migration {
*/
public function up()
{
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
});
}


Expand All @@ -27,7 +27,7 @@ class CreateOrdersTable extends Migration {
*/
public function down()
{
Schema::drop('orders');
Schema::drop('orders');
}

}
8 changes: 4 additions & 4 deletions tests/stubs/DropOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DropOrdersTable extends Migration {
*/
public function up()
{
Schema::drop('orders');
Schema::drop('orders');
}


Expand All @@ -23,11 +23,11 @@ class DropOrdersTable extends Migration {
*/
public function down()
{
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
Schema::create('orders', function(Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->timestamps();
});
});
}

}
2 changes: 1 addition & 1 deletion tests/stubs/Order.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

class Order extends \Eloquent {
protected $fillable = [];
protected $fillable = [];
}
18 changes: 9 additions & 9 deletions tests/stubs/OrdersTableSeeder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use Faker\Factory as Faker;

class OrdersTableSeeder extends Seeder {

public function run()
{
$faker = Faker::create();
public function run()
{
$faker = Faker::create();

foreach(range(1, 10) as $index)
{
Order::create([
foreach(range(1, 10) as $index)
{
Order::create([

]);
}
}
]);
}
}

}
12 changes: 6 additions & 6 deletions tests/stubs/RemoveTitleFromOrdersTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class RemoveTitleFromOrdersTable extends Migration {
*/
public function up()
{
Schema::table('orders', function(Blueprint $table) {
$table->dropColumn('title');
});
Schema::table('orders', function(Blueprint $table) {
$table->dropColumn('title');
});
}


Expand All @@ -25,9 +25,9 @@ class RemoveTitleFromOrdersTable extends Migration {
*/
public function down()
{
Schema::table('orders', function(Blueprint $table) {
$table->string('title');
});
Schema::table('orders', function(Blueprint $table) {
$table->string('title');
});
}

}

0 comments on commit b3c2974

Please sign in to comment.