Change tab to space

Using PSR-2 standard.
This commit is contained in:
Hernawan Fa'iz Abdillah 2016-03-30 14:42:16 +07:00
parent b2510a01e4
commit 942b8fefb4
8 changed files with 64 additions and 64 deletions

View File

@ -2,8 +2,8 @@
class {{name}} extends Controller
{
const MODEL = "{{model}}";
const MODEL = "{{model}}";
use RESTActions;
use RESTActions;
}

View File

@ -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);
}
}

View File

@ -1 +1 @@
'{{name}}' => $faker->{{type}},
'{{name}}' => $faker->{{type}},

View File

@ -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}}

View File

@ -1,4 +1,4 @@
public function {{name}}()
{
return $this->{{type}}("{{model}}")->withTimestamps();
}
public function {{name}}()
{
return $this->{{type}}("{{model}}")->withTimestamps();
}

View File

@ -1,4 +1,4 @@
public function {{name}}()
{
return $this->{{type}}("{{model}}");
}
public function {{name}}()
{
return $this->{{type}}("{{model}}");
}

View File

@ -1 +1 @@
"{{name}}" => "{{rule}}",
"{{name}}" => "{{rule}}",

View File

@ -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)
]);
}
}
}