update server api
|
|
@ -0,0 +1,99 @@
|
|||
<?php namespace AhmadFatoni\ApiGenerator\Controllers\API;
|
||||
|
||||
use Cms\Classes\Controller;
|
||||
use BackendMenu;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use AhmadFatoni\ApiGenerator\Helpers\Helpers;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Atash\Slider\Models\Widy_zayawok;
|
||||
class WidZayawokController extends Controller
|
||||
{
|
||||
protected $Widy_zayawok;
|
||||
|
||||
protected $helpers;
|
||||
|
||||
public function __construct(Widy_zayawok $Widy_zayawok, Helpers $helpers)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->Widy_zayawok = $Widy_zayawok;
|
||||
$this->helpers = $helpers;
|
||||
}
|
||||
|
||||
public function index(){
|
||||
|
||||
$data = $this->Widy_zayawok->with(['translations:locale,model_id,attribute_data','image','file'])->get();
|
||||
|
||||
return $this->helpers->apiArrayResponseBuilder(200, 'success', $data);
|
||||
}
|
||||
|
||||
public function show($id){
|
||||
|
||||
$data = $this->Widy_zayawok::find($id);
|
||||
|
||||
if ($data){
|
||||
return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]);
|
||||
} else {
|
||||
$this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function store(Request $request){
|
||||
|
||||
$arr = $request->all();
|
||||
|
||||
while ( $data = current($arr)) {
|
||||
$this->Widy_zayawok->{key($arr)} = $data;
|
||||
next($arr);
|
||||
}
|
||||
|
||||
$validation = Validator::make($request->all(), $this->Widy_zayawok->rules);
|
||||
|
||||
if( $validation->passes() ){
|
||||
$this->Widy_zayawok->save();
|
||||
return $this->helpers->apiArrayResponseBuilder(201, 'created', ['id' => $this->Widy_zayawok->id]);
|
||||
}else{
|
||||
return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validation->errors() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function update($id, Request $request){
|
||||
|
||||
$status = $this->Widy_zayawok->where('id',$id)->update($data);
|
||||
|
||||
if( $status ){
|
||||
|
||||
return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been updated successfully.');
|
||||
|
||||
}else{
|
||||
|
||||
return $this->helpers->apiArrayResponseBuilder(400, 'bad request', 'Error, data failed to update.');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
$this->Widy_zayawok->where('id',$id)->delete();
|
||||
|
||||
return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.');
|
||||
}
|
||||
|
||||
public function destroy($id){
|
||||
|
||||
$this->Widy_zayawok->where('id',$id)->delete();
|
||||
|
||||
return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.');
|
||||
}
|
||||
|
||||
|
||||
public static function getAfterFilters() {return [];}
|
||||
public static function getBeforeFilters() {return [];}
|
||||
public static function getMiddleware() {return [];}
|
||||
public function callAction($method, $parameters=false) {
|
||||
return call_user_func_array(array($this, $method), $parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,3 +22,5 @@ Route::resource('api/v1/wid_zayawok', 'AhmadFatoni\ApiGenerator\Controllers\API\
|
|||
Route::get('api/v1/wid_zayawok/{id}/delete', ['as' => 'api/v1/wid_zayawok.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\Виды заявокController@destroy']);
|
||||
Route::resource('api/v1/reestr_doc', 'AhmadFatoni\ApiGenerator\Controllers\API\ReestrDocController', ['except' => ['destroy', 'create', 'edit']]);
|
||||
Route::get('api/v1/reestr_doc/{id}/delete', ['as' => 'api/v1/reestr_doc.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\ReestrDocController@destroy']);
|
||||
Route::resource('api/v1/wid_zayawok', 'AhmadFatoni\ApiGenerator\Controllers\API\WidZayawokController', ['except' => ['destroy', 'create', 'edit']]);
|
||||
Route::get('api/v1/wid_zayawok/{id}/delete', ['as' => 'api/v1/wid_zayawok.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\WidZayawokController@destroy']);
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php namespace Atash\Slider\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableUpdateAtashSliderInformasiyaObUslugah extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('atash_slider_informasiya_ob_uslugah', function($table)
|
||||
{
|
||||
$table->text('kind_of_activity')->nullable(false)->unsigned(false)->default(null)->change();
|
||||
$table->text('documents_for_employers')->nullable(false)->unsigned(false)->default(null)->change();
|
||||
$table->text('order')->nullable(false)->unsigned(false)->default(null)->change();
|
||||
$table->text('cost_of_work')->nullable(false)->unsigned(false)->default(null)->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('atash_slider_informasiya_ob_uslugah', function($table)
|
||||
{
|
||||
$table->string('kind_of_activity', 191)->nullable(false)->unsigned(false)->default(null)->change();
|
||||
$table->string('documents_for_employers', 191)->nullable(false)->unsigned(false)->default(null)->change();
|
||||
$table->string('order', 191)->nullable(false)->unsigned(false)->default(null)->change();
|
||||
$table->string('cost_of_work', 191)->nullable(false)->unsigned(false)->default(null)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 413 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 417 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
|
@ -0,0 +1 @@
|
|||
static-pages: { }
|
||||