From 942b8fefb4bcf253e278e3884084748ae7ed05d0 Mon Sep 17 00:00:00 2001 From: Hernawan Fa'iz Abdillah Date: Wed, 30 Mar 2016 14:42:16 +0700 Subject: [PATCH] Change tab to space Using PSR-2 standard. --- templates/controller.wnt | 4 +- templates/controller/rest-actions.wnt | 82 ++++++++++---------- templates/factory/field.wnt | 2 +- templates/model.wnt | 8 +- templates/model/relation-with-timestamps.wnt | 8 +- templates/model/relation.wnt | 8 +- templates/model/rule.wnt | 2 +- templates/pivot-seeder.wnt | 14 ++-- 8 files changed, 64 insertions(+), 64 deletions(-) diff --git a/templates/controller.wnt b/templates/controller.wnt index fdaca3f..d339fb5 100644 --- a/templates/controller.wnt +++ b/templates/controller.wnt @@ -2,8 +2,8 @@ class {{name}} extends Controller { - const MODEL = "{{model}}"; + const MODEL = "{{model}}"; - use RESTActions; + use RESTActions; } diff --git a/templates/controller/rest-actions.wnt b/templates/controller/rest-actions.wnt index 9a88f37..726910e 100644 --- a/templates/controller/rest-actions.wnt +++ b/templates/controller/rest-actions.wnt @@ -6,54 +6,54 @@ use Illuminate\Http\Response; trait RESTActions { - public function all() - { - $m = self::MODEL; - return $this->respond(Response::HTTP_OK, $m::all()); - } + public function all() + { + $m = self::MODEL; + return $this->respond(Response::HTTP_OK, $m::all()); + } - public function get($id) - { - $m = self::MODEL; - $model = $m::find($id); - if(is_null($model)){ - return $this->respond(Response::HTTP_NOT_FOUND); - } - return $this->respond(Response::HTTP_OK, $model); - } + public function get($id) + { + $m = self::MODEL; + $model = $m::find($id); + if(is_null($model)){ + return $this->respond(Response::HTTP_NOT_FOUND); + } + return $this->respond(Response::HTTP_OK, $model); + } - public function add(Request $request) - { - $m = self::MODEL; - $this->validate($request, $m::$rules); - return $this->respond(Response::HTTP_CREATED, $m::create($request->all())); - } + public function add(Request $request) + { + $m = self::MODEL; + $this->validate($request, $m::$rules); + return $this->respond(Response::HTTP_CREATED, $m::create($request->all())); + } - public function put(Request $request, $id) - { - $m = self::MODEL; - $this->validate($request, $m::$rules); - $model = $m::find($id); - if(is_null($model)){ - return $this->respond(Response::HTTP_NOT_FOUND); - } - $model->update($request->all()); - return $this->respond(Response::HTTP_OK, $model); - } + public function put(Request $request, $id) + { + $m = self::MODEL; + $this->validate($request, $m::$rules); + $model = $m::find($id); + if(is_null($model)){ + return $this->respond(Response::HTTP_NOT_FOUND); + } + $model->update($request->all()); + return $this->respond(Response::HTTP_OK, $model); + } - public function remove($id) - { - $m = self::MODEL; - if(is_null($m::find($id))){ - return $this->respond(Response::HTTP_NOT_FOUND); - } - $m::destroy($id); - return $this->respond(Response::HTTP_NO_CONTENT); - } + public function remove($id) + { + $m = self::MODEL; + if(is_null($m::find($id))){ + return $this->respond(Response::HTTP_NOT_FOUND); + } + $m::destroy($id); + return $this->respond(Response::HTTP_NO_CONTENT); + } protected function respond($status, $data = []) { - return response()->json($data, $status); + return response()->json($data, $status); } } diff --git a/templates/factory/field.wnt b/templates/factory/field.wnt index 46d13d1..4250611 100644 --- a/templates/factory/field.wnt +++ b/templates/factory/field.wnt @@ -1 +1 @@ - '{{name}}' => $faker->{{type}}, \ No newline at end of file + '{{name}}' => $faker->{{type}}, \ No newline at end of file diff --git a/templates/model.wnt b/templates/model.wnt index b88f1cd..7b3a1f2 100644 --- a/templates/model.wnt +++ b/templates/model.wnt @@ -4,13 +4,13 @@ use Illuminate\Database\Eloquent\Model; class {{name}} extends Model { - protected $fillable = [{{fillable}}]; + protected $fillable = [{{fillable}}]; - protected $dates = [{{dates}}]; + protected $dates = [{{dates}}]; - public static $rules = [ + public static $rules = [ {{rules}} - ]; + ]; {{relations}} diff --git a/templates/model/relation-with-timestamps.wnt b/templates/model/relation-with-timestamps.wnt index a076005..5fd0dd7 100644 --- a/templates/model/relation-with-timestamps.wnt +++ b/templates/model/relation-with-timestamps.wnt @@ -1,4 +1,4 @@ - public function {{name}}() - { - return $this->{{type}}("{{model}}")->withTimestamps(); - } + public function {{name}}() + { + return $this->{{type}}("{{model}}")->withTimestamps(); + } diff --git a/templates/model/relation.wnt b/templates/model/relation.wnt index e9bef2a..9585502 100644 --- a/templates/model/relation.wnt +++ b/templates/model/relation.wnt @@ -1,4 +1,4 @@ - public function {{name}}() - { - return $this->{{type}}("{{model}}"); - } + public function {{name}}() + { + return $this->{{type}}("{{model}}"); + } diff --git a/templates/model/rule.wnt b/templates/model/rule.wnt index 99d0ea2..3103488 100644 --- a/templates/model/rule.wnt +++ b/templates/model/rule.wnt @@ -1 +1 @@ - "{{name}}" => "{{rule}}", \ No newline at end of file + "{{name}}" => "{{rule}}", \ No newline at end of file diff --git a/templates/pivot-seeder.wnt b/templates/pivot-seeder.wnt index 7e9ca7e..d697cb9 100644 --- a/templates/pivot-seeder.wnt +++ b/templates/pivot-seeder.wnt @@ -7,16 +7,16 @@ class {{name}} extends Seeder { public function run() { - $faker = Faker::create(); + $faker = Faker::create(); - $firstIds = DB::table('{{first_table}}')->lists('id'); - $secondIds = DB::table('{{second_table}}')->lists('id'); + $firstIds = DB::table('{{first_table}}')->lists('id'); + $secondIds = DB::table('{{second_table}}')->lists('id'); for($i = 0; $i < {{count}}; $i++) { - DB::table('{{first_resource}}_{{second_resource}}')->insert([ - '{{first_resource}}_id' => $faker->randomElement($firstIds), - '{{second_resource}}_id' => $faker->randomElement($secondIds) - ]); + DB::table('{{first_resource}}_{{second_resource}}')->insert([ + '{{first_resource}}_id' => $faker->randomElement($firstIds), + '{{second_resource}}_id' => $faker->randomElement($secondIds) + ]); } } }