@@ -35,28 +35,28 @@ |
||
| 35 | 35 | * @var string |
| 36 | 36 | */ |
| 37 | 37 | protected $stubsController = [ |
| 38 | - 'controllers' => [ |
|
| 39 | - 'DashboardEpormasController.stub', |
|
| 40 | - 'EpormasCategoryController.stub', |
|
| 41 | - 'EpormasCityController.stub', |
|
| 42 | - 'EpormasCounterController.stub' |
|
| 43 | - ] |
|
| 38 | + 'controllers' => [ |
|
| 39 | + 'DashboardEpormasController.stub', |
|
| 40 | + 'EpormasCategoryController.stub', |
|
| 41 | + 'EpormasCityController.stub', |
|
| 42 | + 'EpormasCounterController.stub' |
|
| 43 | + ] |
|
| 44 | 44 | ]; |
| 45 | 45 | |
| 46 | 46 | protected $stubsModel = [ |
| 47 | - 'models' => [ |
|
| 48 | - 'EpormasCategory.stub', |
|
| 49 | - 'EpormasCity.stub', |
|
| 50 | - 'EpormasCounter.stub' |
|
| 51 | - ] |
|
| 47 | + 'models' => [ |
|
| 48 | + 'EpormasCategory.stub', |
|
| 49 | + 'EpormasCity.stub', |
|
| 50 | + 'EpormasCounter.stub' |
|
| 51 | + ] |
|
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | 54 | protected $stubsSeeds = [ |
| 55 | - 'seeds' => [ |
|
| 56 | - 'EpormasCategoryTableSeeder.stub', |
|
| 57 | - 'EpormasCityTableSeeder.stub', |
|
| 58 | - 'EpormasCounterTableSeeder.stub' |
|
| 59 | - ] |
|
| 55 | + 'seeds' => [ |
|
| 56 | + 'EpormasCategoryTableSeeder.stub', |
|
| 57 | + 'EpormasCityTableSeeder.stub', |
|
| 58 | + 'EpormasCounterTableSeeder.stub' |
|
| 59 | + ] |
|
| 60 | 60 | ]; |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -6,25 +6,25 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateEpormasCounterTable extends Migration { |
| 8 | 8 | |
| 9 | - public function up() |
|
| 10 | - { |
|
| 11 | - Schema::create('epormas_counter', function(Blueprint $table) { |
|
| 12 | - $table->increments('id'); |
|
| 13 | - $table->timestamps(); |
|
| 14 | - $table->softDeletes(); |
|
| 15 | - $table->integer('tahun')->unsigned()->index(); |
|
| 16 | - $table->string('bulan', 2)->index(); |
|
| 17 | - $table->datetime('tanggal')->index(); |
|
| 18 | - $table->integer('count')->unsigned()->index(); |
|
| 19 | - $table->string('via')->index(); |
|
| 20 | - $table->integer('user_id')->unsigned()->index(); |
|
| 21 | - $table->integer('category_id')->unsigned()->index(); |
|
| 22 | - $table->integer('city_id')->unsigned()->index(); |
|
| 23 | - }); |
|
| 24 | - } |
|
| 9 | + public function up() |
|
| 10 | + { |
|
| 11 | + Schema::create('epormas_counter', function(Blueprint $table) { |
|
| 12 | + $table->increments('id'); |
|
| 13 | + $table->timestamps(); |
|
| 14 | + $table->softDeletes(); |
|
| 15 | + $table->integer('tahun')->unsigned()->index(); |
|
| 16 | + $table->string('bulan', 2)->index(); |
|
| 17 | + $table->datetime('tanggal')->index(); |
|
| 18 | + $table->integer('count')->unsigned()->index(); |
|
| 19 | + $table->string('via')->index(); |
|
| 20 | + $table->integer('user_id')->unsigned()->index(); |
|
| 21 | + $table->integer('category_id')->unsigned()->index(); |
|
| 22 | + $table->integer('city_id')->unsigned()->index(); |
|
| 23 | + }); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function down() |
|
| 27 | - { |
|
| 28 | - Schema::dropIfExists('epormas_counter'); |
|
| 29 | - } |
|
| 26 | + public function down() |
|
| 27 | + { |
|
| 28 | + Schema::dropIfExists('epormas_counter'); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -6,18 +6,18 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateEpormasCityTable extends Migration { |
| 8 | 8 | |
| 9 | - public function up() |
|
| 10 | - { |
|
| 11 | - Schema::create('epormas_city', function(Blueprint $table) { |
|
| 12 | - $table->increments('id'); |
|
| 13 | - $table->timestamps(); |
|
| 14 | - $table->softDeletes(); |
|
| 15 | - $table->string('name', 191)->index(); |
|
| 16 | - }); |
|
| 17 | - } |
|
| 9 | + public function up() |
|
| 10 | + { |
|
| 11 | + Schema::create('epormas_city', function(Blueprint $table) { |
|
| 12 | + $table->increments('id'); |
|
| 13 | + $table->timestamps(); |
|
| 14 | + $table->softDeletes(); |
|
| 15 | + $table->string('name', 191)->index(); |
|
| 16 | + }); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function down() |
|
| 20 | - { |
|
| 21 | - Schema::dropIfExists('epormas_city'); |
|
| 22 | - } |
|
| 19 | + public function down() |
|
| 20 | + { |
|
| 21 | + Schema::dropIfExists('epormas_city'); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -6,18 +6,18 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateEpormasCategoryTable extends Migration { |
| 8 | 8 | |
| 9 | - public function up() |
|
| 10 | - { |
|
| 11 | - Schema::create('epormas_category', function(Blueprint $table) { |
|
| 12 | - $table->increments('id'); |
|
| 13 | - $table->timestamps(); |
|
| 14 | - $table->softDeletes(); |
|
| 15 | - $table->string('name', 191)->index(); |
|
| 16 | - }); |
|
| 17 | - } |
|
| 9 | + public function up() |
|
| 10 | + { |
|
| 11 | + Schema::create('epormas_category', function(Blueprint $table) { |
|
| 12 | + $table->increments('id'); |
|
| 13 | + $table->timestamps(); |
|
| 14 | + $table->softDeletes(); |
|
| 15 | + $table->string('name', 191)->index(); |
|
| 16 | + }); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function down() |
|
| 20 | - { |
|
| 21 | - Schema::dropIfExists('epormas_category'); |
|
| 22 | - } |
|
| 19 | + public function down() |
|
| 20 | + { |
|
| 21 | + Schema::dropIfExists('epormas_category'); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -5,34 +5,34 @@ |
||
| 5 | 5 | |
| 6 | 6 | class EpormasCityTableSeeder extends Seeder { |
| 7 | 7 | |
| 8 | - public function run() |
|
| 9 | - { |
|
| 10 | - //DB::table('epormas_city')->delete(); |
|
| 8 | + public function run() |
|
| 9 | + { |
|
| 10 | + //DB::table('epormas_city')->delete(); |
|
| 11 | 11 | |
| 12 | - // create_epormas_city_20171201000000 |
|
| 13 | - EpormasCity::create(array( |
|
| 14 | - 'name' => 'Kabupaten Pandeglang' |
|
| 15 | - )); |
|
| 16 | - EpormasCity::create(array( |
|
| 17 | - 'name' => 'Kabupaten Lebak' |
|
| 18 | - )); |
|
| 19 | - EpormasCity::create(array( |
|
| 20 | - 'name' => 'Kabupaten Tangerang' |
|
| 21 | - )); |
|
| 22 | - EpormasCity::create(array( |
|
| 23 | - 'name' => 'Kabupaten Serang' |
|
| 24 | - )); |
|
| 25 | - EpormasCity::create(array( |
|
| 26 | - 'name' => 'Kota Tangerang' |
|
| 27 | - )); |
|
| 28 | - EpormasCity::create(array( |
|
| 29 | - 'name' => 'Kota Cilegon' |
|
| 30 | - )); |
|
| 31 | - EpormasCity::create(array( |
|
| 32 | - 'name' => 'Kota Serang' |
|
| 33 | - )); |
|
| 34 | - EpormasCity::create(array( |
|
| 35 | - 'name' => 'Kota Tangerang Selatan' |
|
| 36 | - )); |
|
| 37 | - } |
|
| 12 | + // create_epormas_city_20171201000000 |
|
| 13 | + EpormasCity::create(array( |
|
| 14 | + 'name' => 'Kabupaten Pandeglang' |
|
| 15 | + )); |
|
| 16 | + EpormasCity::create(array( |
|
| 17 | + 'name' => 'Kabupaten Lebak' |
|
| 18 | + )); |
|
| 19 | + EpormasCity::create(array( |
|
| 20 | + 'name' => 'Kabupaten Tangerang' |
|
| 21 | + )); |
|
| 22 | + EpormasCity::create(array( |
|
| 23 | + 'name' => 'Kabupaten Serang' |
|
| 24 | + )); |
|
| 25 | + EpormasCity::create(array( |
|
| 26 | + 'name' => 'Kota Tangerang' |
|
| 27 | + )); |
|
| 28 | + EpormasCity::create(array( |
|
| 29 | + 'name' => 'Kota Cilegon' |
|
| 30 | + )); |
|
| 31 | + EpormasCity::create(array( |
|
| 32 | + 'name' => 'Kota Serang' |
|
| 33 | + )); |
|
| 34 | + EpormasCity::create(array( |
|
| 35 | + 'name' => 'Kota Tangerang Selatan' |
|
| 36 | + )); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -5,13 +5,13 @@ |
||
| 5 | 5 | |
| 6 | 6 | class EpormasCategoryTableSeeder extends Seeder { |
| 7 | 7 | |
| 8 | - public function run() |
|
| 9 | - { |
|
| 10 | - //DB::table('epormas_category')->delete(); |
|
| 8 | + public function run() |
|
| 9 | + { |
|
| 10 | + //DB::table('epormas_category')->delete(); |
|
| 11 | 11 | |
| 12 | - // create_epormas_category_20171201000000 |
|
| 13 | - EpormasCategory::create(array( |
|
| 14 | - 'name' => 'Pendidikan' |
|
| 15 | - )); |
|
| 16 | - } |
|
| 12 | + // create_epormas_category_20171201000000 |
|
| 13 | + EpormasCategory::create(array( |
|
| 14 | + 'name' => 'Pendidikan' |
|
| 15 | + )); |
|
| 16 | + } |
|
| 17 | 17 | } |
@@ -5,20 +5,20 @@ |
||
| 5 | 5 | |
| 6 | 6 | class EpormasCounterTableSeeder extends Seeder { |
| 7 | 7 | |
| 8 | - public function run() |
|
| 9 | - { |
|
| 10 | - //DB::table('epormas_counter')->delete(); |
|
| 8 | + public function run() |
|
| 9 | + { |
|
| 10 | + //DB::table('epormas_counter')->delete(); |
|
| 11 | 11 | |
| 12 | - // create_epormas_counter_20171201000000 |
|
| 13 | - EpormasCounter::create(array( |
|
| 14 | - 'tanggal' => '2017-12-01 00:00:12', |
|
| 15 | - 'count' => 1, |
|
| 16 | - 'via' => 'form', |
|
| 17 | - 'user_id' => 1, |
|
| 18 | - 'tahun' => 2017, |
|
| 19 | - 'bulan' => 12, |
|
| 20 | - 'category_id' => 1, |
|
| 21 | - 'city_id' => 1 |
|
| 22 | - )); |
|
| 23 | - } |
|
| 12 | + // create_epormas_counter_20171201000000 |
|
| 13 | + EpormasCounter::create(array( |
|
| 14 | + 'tanggal' => '2017-12-01 00:00:12', |
|
| 15 | + 'count' => 1, |
|
| 16 | + 'via' => 'form', |
|
| 17 | + 'user_id' => 1, |
|
| 18 | + 'tahun' => 2017, |
|
| 19 | + 'bulan' => 12, |
|
| 20 | + 'category_id' => 1, |
|
| 21 | + 'city_id' => 1 |
|
| 22 | + )); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -14,67 +14,67 @@ discard block |
||
| 14 | 14 | class EpormasCounterController extends Controller |
| 15 | 15 | {
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Display a listing of the resource. |
|
| 19 | - * |
|
| 20 | - * @return Response |
|
| 21 | - */ |
|
| 22 | - public function index() |
|
| 23 | - {
|
|
| 24 | - try {
|
|
| 25 | - $error = false; |
|
| 26 | - $statusCode = 200; |
|
| 27 | - $title = 'Success'; |
|
| 28 | - $type = 'success'; |
|
| 29 | - $message = 'Success'; |
|
| 30 | - $result = EpormasCounter::whereNull('deleted_at')
|
|
| 31 | - ->with('getCity')
|
|
| 32 | - ->with('getCategory')
|
|
| 33 | - ->get(); |
|
| 34 | - } catch (Exception $e) {
|
|
| 35 | - $error = true; |
|
| 36 | - $statusCode = 404; |
|
| 37 | - $title = 'Error'; |
|
| 38 | - $type = 'error'; |
|
| 39 | - $message = 'Error'; |
|
| 40 | - $result = 'Not Found'; |
|
| 41 | - } finally {
|
|
| 42 | - return Response::json(array( |
|
| 17 | + /** |
|
| 18 | + * Display a listing of the resource. |
|
| 19 | + * |
|
| 20 | + * @return Response |
|
| 21 | + */ |
|
| 22 | + public function index() |
|
| 23 | + {
|
|
| 24 | + try {
|
|
| 25 | + $error = false; |
|
| 26 | + $statusCode = 200; |
|
| 27 | + $title = 'Success'; |
|
| 28 | + $type = 'success'; |
|
| 29 | + $message = 'Success'; |
|
| 30 | + $result = EpormasCounter::whereNull('deleted_at')
|
|
| 31 | + ->with('getCity')
|
|
| 32 | + ->with('getCategory')
|
|
| 33 | + ->get(); |
|
| 34 | + } catch (Exception $e) {
|
|
| 35 | + $error = true; |
|
| 36 | + $statusCode = 404; |
|
| 37 | + $title = 'Error'; |
|
| 38 | + $type = 'error'; |
|
| 39 | + $message = 'Error'; |
|
| 40 | + $result = 'Not Found'; |
|
| 41 | + } finally {
|
|
| 42 | + return Response::json(array( |
|
| 43 | 43 | 'error' => $error, |
| 44 | 44 | 'status' => $statusCode, |
| 45 | 45 | 'title' => $title, |
| 46 | 46 | 'type' => $type, |
| 47 | 47 | 'message' => $message, |
| 48 | 48 | 'result' => $result |
| 49 | - )); |
|
| 50 | - } |
|
| 51 | - } |
|
| 49 | + )); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Show the form for creating a new resource. |
|
| 55 | - * |
|
| 56 | - * @return Response |
|
| 57 | - */ |
|
| 58 | - public function create() |
|
| 59 | - {
|
|
| 60 | - try {
|
|
| 61 | - $error = false; |
|
| 62 | - $statusCode = 200; |
|
| 63 | - $title = 'Success'; |
|
| 64 | - $type = 'success'; |
|
| 65 | - $message = 'Success'; |
|
| 66 | - $city = EpormasCity::all(); |
|
| 67 | - $category = EpormasCategory::all(); |
|
| 68 | - } catch (Exception $e) {
|
|
| 69 | - $error = true; |
|
| 70 | - $statusCode = 404; |
|
| 71 | - $title = 'Error'; |
|
| 72 | - $type = 'error'; |
|
| 73 | - $message = 'Error'; |
|
| 74 | - $city = 'Not Found'; |
|
| 75 | - $category = 'Not Found'; |
|
| 76 | - } finally {
|
|
| 77 | - return Response::json(array( |
|
| 53 | + /** |
|
| 54 | + * Show the form for creating a new resource. |
|
| 55 | + * |
|
| 56 | + * @return Response |
|
| 57 | + */ |
|
| 58 | + public function create() |
|
| 59 | + {
|
|
| 60 | + try {
|
|
| 61 | + $error = false; |
|
| 62 | + $statusCode = 200; |
|
| 63 | + $title = 'Success'; |
|
| 64 | + $type = 'success'; |
|
| 65 | + $message = 'Success'; |
|
| 66 | + $city = EpormasCity::all(); |
|
| 67 | + $category = EpormasCategory::all(); |
|
| 68 | + } catch (Exception $e) {
|
|
| 69 | + $error = true; |
|
| 70 | + $statusCode = 404; |
|
| 71 | + $title = 'Error'; |
|
| 72 | + $type = 'error'; |
|
| 73 | + $message = 'Error'; |
|
| 74 | + $city = 'Not Found'; |
|
| 75 | + $category = 'Not Found'; |
|
| 76 | + } finally {
|
|
| 77 | + return Response::json(array( |
|
| 78 | 78 | 'error' => $error, |
| 79 | 79 | 'status' => $statusCode, |
| 80 | 80 | 'title' => $title, |
@@ -82,31 +82,31 @@ discard block |
||
| 82 | 82 | 'message' => $message, |
| 83 | 83 | 'city' => $city, |
| 84 | 84 | 'category' => $category |
| 85 | - )); |
|
| 86 | - } |
|
| 87 | - } |
|
| 85 | + )); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Store a newly created resource in storage. |
|
| 91 | - * |
|
| 92 | - * @return Response |
|
| 93 | - */ |
|
| 94 | - public function store(Request $request, $version='') |
|
| 95 | - {
|
|
| 89 | + /** |
|
| 90 | + * Store a newly created resource in storage. |
|
| 91 | + * |
|
| 92 | + * @return Response |
|
| 93 | + */ |
|
| 94 | + public function store(Request $request, $version='') |
|
| 95 | + {
|
|
| 96 | 96 | $path = \Request::path(); |
| 97 | 97 | $explode = explode('/', $path);
|
| 98 | 98 | |
| 99 | 99 | $from = 'form'; |
| 100 | 100 | if(in_array('api',$explode)){
|
| 101 | - $from = 'api'; |
|
| 101 | + $from = 'api'; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $via = $from; |
| 105 | 105 | if($version != '' && $version != 'store'){
|
| 106 | - $via .= '-'.$version; |
|
| 106 | + $via .= '-'.$version; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $rules = [ |
|
| 109 | + $rules = [ |
|
| 110 | 110 | 'count' => 'required|numeric', |
| 111 | 111 | 'city_id' => 'required|numeric', |
| 112 | 112 | 'category_id' => 'required|numeric', |
@@ -115,44 +115,44 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $validator = Validator::make($request->all(), $rules); |
| 117 | 117 | if ($validator->fails()) {
|
| 118 | - return response()->json([ |
|
| 119 | - 'title' => 'Error', |
|
| 120 | - 'type' => 'error', |
|
| 121 | - 'message' => $validator->errors()->all() |
|
| 122 | - ]); |
|
| 118 | + return response()->json([ |
|
| 119 | + 'title' => 'Error', |
|
| 120 | + 'type' => 'error', |
|
| 121 | + 'message' => $validator->errors()->all() |
|
| 122 | + ]); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
| 126 | 126 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 127 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 128 | - ->where('category_id',$request->category_id)
|
|
| 129 | - ->where('city_id',$request->city_id)
|
|
| 130 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 131 | - ->orderBy('bulan')
|
|
| 132 | - ->count(); |
|
| 127 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 128 | + ->where('category_id',$request->category_id)
|
|
| 129 | + ->where('city_id',$request->city_id)
|
|
| 130 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 131 | + ->orderBy('bulan')
|
|
| 132 | + ->count(); |
|
| 133 | 133 | if($resultcek > 0){
|
| 134 | - return response()->json([ |
|
| 135 | - 'title' => 'Error', |
|
| 136 | - 'type' => 'error', |
|
| 137 | - 'message' => 'Data has already been taken.' |
|
| 138 | - ]); |
|
| 134 | + return response()->json([ |
|
| 135 | + 'title' => 'Error', |
|
| 136 | + 'type' => 'error', |
|
| 137 | + 'message' => 'Data has already been taken.' |
|
| 138 | + ]); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $date = explode("-",$format);
|
| 142 | 142 | $data = EpormasCounter::whereNull('deleted_at')
|
| 143 | - ->where('tahun', $date[0])
|
|
| 144 | - ->where('bulan', $date[1])
|
|
| 145 | - ->where('category_id',$request->category_id)
|
|
| 146 | - ->where('city_id',$request->city_id)
|
|
| 147 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 148 | - ->orderBy('bulan')
|
|
| 149 | - ->count(); |
|
| 143 | + ->where('tahun', $date[0])
|
|
| 144 | + ->where('bulan', $date[1])
|
|
| 145 | + ->where('category_id',$request->category_id)
|
|
| 146 | + ->where('city_id',$request->city_id)
|
|
| 147 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 148 | + ->orderBy('bulan')
|
|
| 149 | + ->count(); |
|
| 150 | 150 | if($data > 0){
|
| 151 | - return response()->json([ |
|
| 152 | - 'title' => 'Error', |
|
| 153 | - 'type' => 'error', |
|
| 154 | - 'message' => 'Data has already been taken.' |
|
| 155 | - ]); |
|
| 151 | + return response()->json([ |
|
| 152 | + 'title' => 'Error', |
|
| 153 | + 'type' => 'error', |
|
| 154 | + 'message' => 'Data has already been taken.' |
|
| 155 | + ]); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | try {
|
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | $result = 'Not Found'; |
| 181 | 181 | } finally {
|
| 182 | 182 | return Response::json(array( |
| 183 | - 'error' => $error, |
|
| 184 | - 'status' => $statusCode, |
|
| 185 | - 'title' => $title, |
|
| 186 | - 'type' => $type, |
|
| 187 | - 'message' => $message, |
|
| 188 | - 'result' => $result |
|
| 183 | + 'error' => $error, |
|
| 184 | + 'status' => $statusCode, |
|
| 185 | + 'title' => $title, |
|
| 186 | + 'type' => $type, |
|
| 187 | + 'message' => $message, |
|
| 188 | + 'result' => $result |
|
| 189 | 189 | )); |
| 190 | 190 | } |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Display the specified resource. |
|
| 195 | - * |
|
| 196 | - * @param int $id |
|
| 197 | - * @return Response |
|
| 198 | - */ |
|
| 199 | - public function show($version='', $id) |
|
| 200 | - {
|
|
| 193 | + /** |
|
| 194 | + * Display the specified resource. |
|
| 195 | + * |
|
| 196 | + * @param int $id |
|
| 197 | + * @return Response |
|
| 198 | + */ |
|
| 199 | + public function show($version='', $id) |
|
| 200 | + {
|
|
| 201 | 201 | try {
|
| 202 | 202 | $error = false; |
| 203 | 203 | $statusCode = 200; |
@@ -217,24 +217,24 @@ discard block |
||
| 217 | 217 | $result = 'Not Found'; |
| 218 | 218 | } finally {
|
| 219 | 219 | return Response::json(array( |
| 220 | - 'error' => $error, |
|
| 221 | - 'status' => $statusCode, |
|
| 222 | - 'title' => $title, |
|
| 223 | - 'type' => $type, |
|
| 224 | - 'message' => $message, |
|
| 225 | - 'result' => $result |
|
| 220 | + 'error' => $error, |
|
| 221 | + 'status' => $statusCode, |
|
| 222 | + 'title' => $title, |
|
| 223 | + 'type' => $type, |
|
| 224 | + 'message' => $message, |
|
| 225 | + 'result' => $result |
|
| 226 | 226 | )); |
| 227 | 227 | } |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Show the form for editing the specified resource. |
|
| 232 | - * |
|
| 233 | - * @param int $id |
|
| 234 | - * @return Response |
|
| 235 | - */ |
|
| 236 | - public function edit($id) |
|
| 237 | - {
|
|
| 230 | + /** |
|
| 231 | + * Show the form for editing the specified resource. |
|
| 232 | + * |
|
| 233 | + * @param int $id |
|
| 234 | + * @return Response |
|
| 235 | + */ |
|
| 236 | + public function edit($id) |
|
| 237 | + {
|
|
| 238 | 238 | try {
|
| 239 | 239 | $error = false; |
| 240 | 240 | $statusCode = 200; |
@@ -260,27 +260,27 @@ discard block |
||
| 260 | 260 | $category = 'Not Found'; |
| 261 | 261 | } finally {
|
| 262 | 262 | return Response::json(array( |
| 263 | - 'error' => $error, |
|
| 264 | - 'status' => $statusCode, |
|
| 265 | - 'title' => $title, |
|
| 266 | - 'type' => $type, |
|
| 267 | - 'message' => $message, |
|
| 268 | - 'result' => $result, |
|
| 269 | - 'city' => $city, |
|
| 270 | - 'tanggal' => $format, |
|
| 271 | - 'category' => $category, |
|
| 263 | + 'error' => $error, |
|
| 264 | + 'status' => $statusCode, |
|
| 265 | + 'title' => $title, |
|
| 266 | + 'type' => $type, |
|
| 267 | + 'message' => $message, |
|
| 268 | + 'result' => $result, |
|
| 269 | + 'city' => $city, |
|
| 270 | + 'tanggal' => $format, |
|
| 271 | + 'category' => $category, |
|
| 272 | 272 | )); |
| 273 | 273 | } |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Update the specified resource in storage. |
|
| 278 | - * |
|
| 279 | - * @param int $id |
|
| 280 | - * @return Response |
|
| 281 | - */ |
|
| 282 | - public function update(Request $request, $version='', $id) |
|
| 283 | - {
|
|
| 276 | + /** |
|
| 277 | + * Update the specified resource in storage. |
|
| 278 | + * |
|
| 279 | + * @param int $id |
|
| 280 | + * @return Response |
|
| 281 | + */ |
|
| 282 | + public function update(Request $request, $version='', $id) |
|
| 283 | + {
|
|
| 284 | 284 | $result = EpormasCounter::whereNull('deleted_at')
|
| 285 | 285 | ->with('getCity')
|
| 286 | 286 | ->with('getCategory')
|
@@ -295,28 +295,28 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | $validator = Validator::make($request->all(), $rules); |
| 297 | 297 | if ($validator->fails()) {
|
| 298 | - return response()->json([ |
|
| 299 | - 'title' => 'Error', |
|
| 300 | - 'type' => 'error', |
|
| 301 | - 'message' => $validator->errors()->all() |
|
| 302 | - ]); |
|
| 298 | + return response()->json([ |
|
| 299 | + 'title' => 'Error', |
|
| 300 | + 'type' => 'error', |
|
| 301 | + 'message' => $validator->errors()->all() |
|
| 302 | + ]); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $format = date('Y-m-d', strtotime(str_replace(' ','-',$request->tanggal)));
|
| 306 | 306 | if($result->city_id != $request->city_id || $result->category_id != $request->category_id){
|
| 307 | 307 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 308 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 309 | - ->where('category_id',$request->category_id)
|
|
| 310 | - ->where('city_id',$request->city_id)
|
|
| 311 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 312 | - ->orderBy('bulan')
|
|
| 313 | - ->count(); |
|
| 308 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 309 | + ->where('category_id',$request->category_id)
|
|
| 310 | + ->where('city_id',$request->city_id)
|
|
| 311 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 312 | + ->orderBy('bulan')
|
|
| 313 | + ->count(); |
|
| 314 | 314 | if($resultcek > 0){
|
| 315 | - return response()->json([ |
|
| 316 | - 'title' => 'Error', |
|
| 317 | - 'type' => 'error', |
|
| 318 | - 'message' => 'Data has already been taken.' |
|
| 319 | - ]); |
|
| 315 | + return response()->json([ |
|
| 316 | + 'title' => 'Error', |
|
| 317 | + 'type' => 'error', |
|
| 318 | + 'message' => 'Data has already been taken.' |
|
| 319 | + ]); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
@@ -324,34 +324,34 @@ discard block |
||
| 324 | 324 | $dates = date('Y-m-d', strtotime($result->tanggal));
|
| 325 | 325 | if($dates != $format){
|
| 326 | 326 | $resultcek = EpormasCounter::whereNull('deleted_at')
|
| 327 | - ->where('category_id',$request->category_id)
|
|
| 328 | - ->where('city_id',$request->city_id)
|
|
| 329 | - ->where('tanggal','like','%'.$format.'%')
|
|
| 330 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 331 | - ->orderBy('bulan')
|
|
| 332 | - ->count(); |
|
| 327 | + ->where('category_id',$request->category_id)
|
|
| 328 | + ->where('city_id',$request->city_id)
|
|
| 329 | + ->where('tanggal','like','%'.$format.'%')
|
|
| 330 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 331 | + ->orderBy('bulan')
|
|
| 332 | + ->count(); |
|
| 333 | 333 | if($resultcek > 0){
|
| 334 | - return response()->json([ |
|
| 335 | - 'title' => 'Error', |
|
| 336 | - 'type' => 'error', |
|
| 337 | - 'message' => 'Data has already been taken.' |
|
| 338 | - ]); |
|
| 334 | + return response()->json([ |
|
| 335 | + 'title' => 'Error', |
|
| 336 | + 'type' => 'error', |
|
| 337 | + 'message' => 'Data has already been taken.' |
|
| 338 | + ]); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | $data = EpormasCounter::whereNull('deleted_at')
|
| 342 | - ->where('tahun', $date[0])
|
|
| 343 | - ->where('bulan', $date[1])
|
|
| 344 | - ->where('category_id',$request->category_id)
|
|
| 345 | - ->where('city_id',$request->city_id)
|
|
| 346 | - ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 347 | - ->orderBy('bulan')
|
|
| 348 | - ->count(); |
|
| 342 | + ->where('tahun', $date[0])
|
|
| 343 | + ->where('bulan', $date[1])
|
|
| 344 | + ->where('category_id',$request->category_id)
|
|
| 345 | + ->where('city_id',$request->city_id)
|
|
| 346 | + ->groupBy('tahun','bulan','category_id','city_id')
|
|
| 347 | + ->orderBy('bulan')
|
|
| 348 | + ->count(); |
|
| 349 | 349 | if($data > 0){
|
| 350 | - return response()->json([ |
|
| 351 | - 'title' => 'Error', |
|
| 352 | - 'type' => 'error', |
|
| 353 | - 'message' => 'Data has already been taken.' |
|
| 354 | - ]); |
|
| 350 | + return response()->json([ |
|
| 351 | + 'title' => 'Error', |
|
| 352 | + 'type' => 'error', |
|
| 353 | + 'message' => 'Data has already been taken.' |
|
| 354 | + ]); |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
@@ -361,13 +361,13 @@ discard block |
||
| 361 | 361 | $from = $result->via; |
| 362 | 362 | $user_id = $result->user_id; |
| 363 | 363 | if(in_array('api',$explode)){
|
| 364 | - $from = 'api'; |
|
| 365 | - $user_id = $request->user_id; |
|
| 364 | + $from = 'api'; |
|
| 365 | + $user_id = $request->user_id; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $via = $from; |
| 369 | 369 | if($version != '' && $version != 'update'){
|
| 370 | - $via .= '-'.$version; |
|
| 370 | + $via .= '-'.$version; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | try {
|
@@ -395,47 +395,47 @@ discard block |
||
| 395 | 395 | $result = 'Not Found'; |
| 396 | 396 | } finally {
|
| 397 | 397 | return Response::json(array( |
| 398 | - 'error' => $error, |
|
| 399 | - 'status' => $statusCode, |
|
| 400 | - 'title' => $title, |
|
| 401 | - 'type' => $type, |
|
| 402 | - 'message' => $message, |
|
| 403 | - 'result' => $result |
|
| 398 | + 'error' => $error, |
|
| 399 | + 'status' => $statusCode, |
|
| 400 | + 'title' => $title, |
|
| 401 | + 'type' => $type, |
|
| 402 | + 'message' => $message, |
|
| 403 | + 'result' => $result |
|
| 404 | 404 | )); |
| 405 | 405 | } |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Remove the specified resource from storage. |
|
| 410 | - * |
|
| 411 | - * @param int $id |
|
| 412 | - * @return Response |
|
| 413 | - */ |
|
| 414 | - public function destroy($id) |
|
| 415 | - {
|
|
| 416 | - try {
|
|
| 417 | - EpormasCounter::find($id)->delete(); |
|
| 418 | - $error = false; |
|
| 419 | - $statusCode = 200; |
|
| 420 | - $title = 'Success'; |
|
| 421 | - $type = 'success'; |
|
| 422 | - $message = 'Data deleted successfully'; |
|
| 423 | - } catch (Exception $e) {
|
|
| 424 | - $error = true; |
|
| 425 | - $statusCode = 404; |
|
| 426 | - $title = 'Error'; |
|
| 427 | - $type = 'error'; |
|
| 428 | - $message = 'Error'; |
|
| 429 | - } finally {
|
|
| 430 | - return Response::json(array( |
|
| 408 | + /** |
|
| 409 | + * Remove the specified resource from storage. |
|
| 410 | + * |
|
| 411 | + * @param int $id |
|
| 412 | + * @return Response |
|
| 413 | + */ |
|
| 414 | + public function destroy($id) |
|
| 415 | + {
|
|
| 416 | + try {
|
|
| 417 | + EpormasCounter::find($id)->delete(); |
|
| 418 | + $error = false; |
|
| 419 | + $statusCode = 200; |
|
| 420 | + $title = 'Success'; |
|
| 421 | + $type = 'success'; |
|
| 422 | + $message = 'Data deleted successfully'; |
|
| 423 | + } catch (Exception $e) {
|
|
| 424 | + $error = true; |
|
| 425 | + $statusCode = 404; |
|
| 426 | + $title = 'Error'; |
|
| 427 | + $type = 'error'; |
|
| 428 | + $message = 'Error'; |
|
| 429 | + } finally {
|
|
| 430 | + return Response::json(array( |
|
| 431 | 431 | 'error' => $error, |
| 432 | 432 | 'status' => $statusCode, |
| 433 | 433 | 'title' => $title, |
| 434 | 434 | 'type' => $type, |
| 435 | 435 | 'message' => $message |
| 436 | - )); |
|
| 437 | - } |
|
| 438 | - } |
|
| 436 | + )); |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | 440 | } |
| 441 | 441 | |
@@ -12,91 +12,91 @@ discard block |
||
| 12 | 12 | class EpormasCityController extends Controller |
| 13 | 13 | {
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Display a listing of the resource. |
|
| 17 | - * |
|
| 18 | - * @return Response |
|
| 19 | - */ |
|
| 20 | - public function index() |
|
| 21 | - {
|
|
| 22 | - try {
|
|
| 23 | - $error = false; |
|
| 24 | - $statusCode = 200; |
|
| 25 | - $title = 'Success'; |
|
| 26 | - $type = 'success'; |
|
| 27 | - $message = 'Success'; |
|
| 28 | - $result = EpormasCity::all(); |
|
| 29 | - } catch (Exception $e) {
|
|
| 30 | - $error = true; |
|
| 31 | - $statusCode = 404; |
|
| 32 | - $title = 'Error'; |
|
| 33 | - $type = 'error'; |
|
| 34 | - $message = 'Error'; |
|
| 35 | - $result = 'Not Found'; |
|
| 36 | - } finally {
|
|
| 37 | - return Response::json(array( |
|
| 15 | + /** |
|
| 16 | + * Display a listing of the resource. |
|
| 17 | + * |
|
| 18 | + * @return Response |
|
| 19 | + */ |
|
| 20 | + public function index() |
|
| 21 | + {
|
|
| 22 | + try {
|
|
| 23 | + $error = false; |
|
| 24 | + $statusCode = 200; |
|
| 25 | + $title = 'Success'; |
|
| 26 | + $type = 'success'; |
|
| 27 | + $message = 'Success'; |
|
| 28 | + $result = EpormasCity::all(); |
|
| 29 | + } catch (Exception $e) {
|
|
| 30 | + $error = true; |
|
| 31 | + $statusCode = 404; |
|
| 32 | + $title = 'Error'; |
|
| 33 | + $type = 'error'; |
|
| 34 | + $message = 'Error'; |
|
| 35 | + $result = 'Not Found'; |
|
| 36 | + } finally {
|
|
| 37 | + return Response::json(array( |
|
| 38 | 38 | 'error' => $error, |
| 39 | 39 | 'status' => $statusCode, |
| 40 | 40 | 'title' => $title, |
| 41 | 41 | 'type' => $type, |
| 42 | 42 | 'message' => $message, |
| 43 | 43 | 'result' => $result |
| 44 | - )); |
|
| 45 | - } |
|
| 46 | - } |
|
| 44 | + )); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Show the form for creating a new resource. |
|
| 50 | - * |
|
| 51 | - * @return Response |
|
| 52 | - */ |
|
| 53 | - public function create() |
|
| 54 | - {
|
|
| 48 | + /** |
|
| 49 | + * Show the form for creating a new resource. |
|
| 50 | + * |
|
| 51 | + * @return Response |
|
| 52 | + */ |
|
| 53 | + public function create() |
|
| 54 | + {
|
|
| 55 | 55 | |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Store a newly created resource in storage. |
|
| 60 | - * |
|
| 61 | - * @return Response |
|
| 62 | - */ |
|
| 63 | - public function store(Request $request, $version='') |
|
| 64 | - {
|
|
| 58 | + /** |
|
| 59 | + * Store a newly created resource in storage. |
|
| 60 | + * |
|
| 61 | + * @return Response |
|
| 62 | + */ |
|
| 63 | + public function store(Request $request, $version='') |
|
| 64 | + {
|
|
| 65 | 65 | $path = \Request::path(); |
| 66 | 66 | $explode = explode('/', $path);
|
| 67 | 67 | |
| 68 | 68 | $from = 'form'; |
| 69 | 69 | if(in_array('api',$explode)){
|
| 70 | - $from = 'api'; |
|
| 70 | + $from = 'api'; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $via = $from; |
| 74 | 74 | if($version != '' && $version != 'store'){
|
| 75 | - $via .= '-'.$version; |
|
| 75 | + $via .= '-'.$version; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $rules = [ |
|
| 78 | + $rules = [ |
|
| 79 | 79 | 'name' => 'required' |
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | $validator = Validator::make($request->all(), $rules); |
| 83 | 83 | if ($validator->fails()) {
|
| 84 | - return response()->json([ |
|
| 85 | - 'title' => 'Error', |
|
| 86 | - 'type' => 'error', |
|
| 87 | - 'message' => $validator->errors()->all() |
|
| 88 | - ]); |
|
| 84 | + return response()->json([ |
|
| 85 | + 'title' => 'Error', |
|
| 86 | + 'type' => 'error', |
|
| 87 | + 'message' => $validator->errors()->all() |
|
| 88 | + ]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $data = EpormasCity::whereNull('deleted_at')
|
| 92 | 92 | ->where('name', $request->name)
|
| 93 | 93 | ->count(); |
| 94 | 94 | if($data > 0){
|
| 95 | - return response()->json([ |
|
| 96 | - 'title' => 'Error', |
|
| 97 | - 'type' => 'error', |
|
| 98 | - 'message' => 'Data has already been taken.' |
|
| 99 | - ]); |
|
| 95 | + return response()->json([ |
|
| 96 | + 'title' => 'Error', |
|
| 97 | + 'type' => 'error', |
|
| 98 | + 'message' => 'Data has already been taken.' |
|
| 99 | + ]); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | try {
|
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | $result = 'Not Found'; |
| 118 | 118 | } finally {
|
| 119 | 119 | return Response::json(array( |
| 120 | - 'error' => $error, |
|
| 121 | - 'status' => $statusCode, |
|
| 122 | - 'title' => $title, |
|
| 123 | - 'type' => $type, |
|
| 124 | - 'message' => $message, |
|
| 125 | - 'result' => $result |
|
| 120 | + 'error' => $error, |
|
| 121 | + 'status' => $statusCode, |
|
| 122 | + 'title' => $title, |
|
| 123 | + 'type' => $type, |
|
| 124 | + 'message' => $message, |
|
| 125 | + 'result' => $result |
|
| 126 | 126 | )); |
| 127 | 127 | } |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Display the specified resource. |
|
| 132 | - * |
|
| 133 | - * @param int $id |
|
| 134 | - * @return Response |
|
| 135 | - */ |
|
| 136 | - public function show($version='', $id) |
|
| 137 | - {
|
|
| 130 | + /** |
|
| 131 | + * Display the specified resource. |
|
| 132 | + * |
|
| 133 | + * @param int $id |
|
| 134 | + * @return Response |
|
| 135 | + */ |
|
| 136 | + public function show($version='', $id) |
|
| 137 | + {
|
|
| 138 | 138 | try {
|
| 139 | 139 | $error = false; |
| 140 | 140 | $statusCode = 200; |
@@ -151,24 +151,24 @@ discard block |
||
| 151 | 151 | $result = 'Not Found'; |
| 152 | 152 | } finally {
|
| 153 | 153 | return Response::json(array( |
| 154 | - 'error' => $error, |
|
| 155 | - 'status' => $statusCode, |
|
| 156 | - 'title' => $title, |
|
| 157 | - 'type' => $type, |
|
| 158 | - 'message' => $message, |
|
| 159 | - 'result' => $result |
|
| 154 | + 'error' => $error, |
|
| 155 | + 'status' => $statusCode, |
|
| 156 | + 'title' => $title, |
|
| 157 | + 'type' => $type, |
|
| 158 | + 'message' => $message, |
|
| 159 | + 'result' => $result |
|
| 160 | 160 | )); |
| 161 | 161 | } |
| 162 | - } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Show the form for editing the specified resource. |
|
| 166 | - * |
|
| 167 | - * @param int $id |
|
| 168 | - * @return Response |
|
| 169 | - */ |
|
| 170 | - public function edit($id) |
|
| 171 | - {
|
|
| 164 | + /** |
|
| 165 | + * Show the form for editing the specified resource. |
|
| 166 | + * |
|
| 167 | + * @param int $id |
|
| 168 | + * @return Response |
|
| 169 | + */ |
|
| 170 | + public function edit($id) |
|
| 171 | + {
|
|
| 172 | 172 | try {
|
| 173 | 173 | $error = false; |
| 174 | 174 | $statusCode = 200; |
@@ -185,24 +185,24 @@ discard block |
||
| 185 | 185 | $result = 'Not Found'; |
| 186 | 186 | } finally {
|
| 187 | 187 | return Response::json(array( |
| 188 | - 'error' => $error, |
|
| 189 | - 'status' => $statusCode, |
|
| 190 | - 'title' => $title, |
|
| 191 | - 'type' => $type, |
|
| 192 | - 'message' => $message, |
|
| 193 | - 'result' => $result |
|
| 188 | + 'error' => $error, |
|
| 189 | + 'status' => $statusCode, |
|
| 190 | + 'title' => $title, |
|
| 191 | + 'type' => $type, |
|
| 192 | + 'message' => $message, |
|
| 193 | + 'result' => $result |
|
| 194 | 194 | )); |
| 195 | 195 | } |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Update the specified resource in storage. |
|
| 200 | - * |
|
| 201 | - * @param int $id |
|
| 202 | - * @return Response |
|
| 203 | - */ |
|
| 204 | - public function update(Request $request, $version='', $id) |
|
| 205 | - {
|
|
| 198 | + /** |
|
| 199 | + * Update the specified resource in storage. |
|
| 200 | + * |
|
| 201 | + * @param int $id |
|
| 202 | + * @return Response |
|
| 203 | + */ |
|
| 204 | + public function update(Request $request, $version='', $id) |
|
| 205 | + {
|
|
| 206 | 206 | $result = EpormasCity::find($id); |
| 207 | 207 | |
| 208 | 208 | $rules = [ |
@@ -211,24 +211,24 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $validator = Validator::make($request->all(), $rules); |
| 213 | 213 | if ($validator->fails()) {
|
| 214 | - return response()->json([ |
|
| 215 | - 'title' => 'Error', |
|
| 216 | - 'type' => 'error', |
|
| 217 | - 'message' => $validator->errors()->all() |
|
| 218 | - ]); |
|
| 214 | + return response()->json([ |
|
| 215 | + 'title' => 'Error', |
|
| 216 | + 'type' => 'error', |
|
| 217 | + 'message' => $validator->errors()->all() |
|
| 218 | + ]); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if($request->name != $result->name){
|
| 222 | - $data = EpormasCity::whereNull('deleted_at')
|
|
| 223 | - ->where('name', $request->name)
|
|
| 224 | - ->count(); |
|
| 225 | - if($data > 0){
|
|
| 222 | + $data = EpormasCity::whereNull('deleted_at')
|
|
| 223 | + ->where('name', $request->name)
|
|
| 224 | + ->count(); |
|
| 225 | + if($data > 0){
|
|
| 226 | 226 | return response()->json([ |
| 227 | 227 | 'title' => 'Error', |
| 228 | 228 | 'type' => 'error', |
| 229 | 229 | 'message' => 'Data has already been taken.' |
| 230 | 230 | ]); |
| 231 | - } |
|
| 231 | + } |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $path = \Request::path(); |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $from = 'form'; |
| 238 | 238 | if(in_array('api',$explode)){
|
| 239 | - $from = 'api'; |
|
| 239 | + $from = 'api'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $via = $from; |
| 243 | 243 | if($version != '' && $version != 'update'){
|
| 244 | - $via .= '-'.$version; |
|
| 244 | + $via .= '-'.$version; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | try {
|
@@ -262,47 +262,47 @@ discard block |
||
| 262 | 262 | $result = 'Not Found'; |
| 263 | 263 | } finally {
|
| 264 | 264 | return Response::json(array( |
| 265 | - 'error' => $error, |
|
| 266 | - 'status' => $statusCode, |
|
| 267 | - 'title' => $title, |
|
| 268 | - 'type' => $type, |
|
| 269 | - 'message' => $message, |
|
| 270 | - 'result' => $result |
|
| 265 | + 'error' => $error, |
|
| 266 | + 'status' => $statusCode, |
|
| 267 | + 'title' => $title, |
|
| 268 | + 'type' => $type, |
|
| 269 | + 'message' => $message, |
|
| 270 | + 'result' => $result |
|
| 271 | 271 | )); |
| 272 | 272 | } |
| 273 | - } |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Remove the specified resource from storage. |
|
| 277 | - * |
|
| 278 | - * @param int $id |
|
| 279 | - * @return Response |
|
| 280 | - */ |
|
| 281 | - public function destroy($id) |
|
| 282 | - {
|
|
| 283 | - try {
|
|
| 284 | - EpormasCity::find($id)->delete(); |
|
| 285 | - $error = false; |
|
| 286 | - $statusCode = 200; |
|
| 287 | - $title = 'Success'; |
|
| 288 | - $type = 'success'; |
|
| 289 | - $message = 'Data deleted successfully'; |
|
| 290 | - } catch (Exception $e) {
|
|
| 291 | - $error = true; |
|
| 292 | - $statusCode = 404; |
|
| 293 | - $title = 'Error'; |
|
| 294 | - $type = 'error'; |
|
| 295 | - $message = 'Error'; |
|
| 296 | - } finally {
|
|
| 297 | - return Response::json(array( |
|
| 275 | + /** |
|
| 276 | + * Remove the specified resource from storage. |
|
| 277 | + * |
|
| 278 | + * @param int $id |
|
| 279 | + * @return Response |
|
| 280 | + */ |
|
| 281 | + public function destroy($id) |
|
| 282 | + {
|
|
| 283 | + try {
|
|
| 284 | + EpormasCity::find($id)->delete(); |
|
| 285 | + $error = false; |
|
| 286 | + $statusCode = 200; |
|
| 287 | + $title = 'Success'; |
|
| 288 | + $type = 'success'; |
|
| 289 | + $message = 'Data deleted successfully'; |
|
| 290 | + } catch (Exception $e) {
|
|
| 291 | + $error = true; |
|
| 292 | + $statusCode = 404; |
|
| 293 | + $title = 'Error'; |
|
| 294 | + $type = 'error'; |
|
| 295 | + $message = 'Error'; |
|
| 296 | + } finally {
|
|
| 297 | + return Response::json(array( |
|
| 298 | 298 | 'error' => $error, |
| 299 | 299 | 'status' => $statusCode, |
| 300 | 300 | 'title' => $title, |
| 301 | 301 | 'type' => $type, |
| 302 | 302 | 'message' => $message |
| 303 | - )); |
|
| 304 | - } |
|
| 305 | - } |
|
| 303 | + )); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |