mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01:00
commit
f90adb27e3
@ -4,6 +4,7 @@ use Auth;
|
||||
use Utils;
|
||||
use Response;
|
||||
use Input;
|
||||
use Validator;
|
||||
use Cache;
|
||||
use App\Models\Client;
|
||||
use App\Models\Account;
|
||||
@ -101,4 +102,42 @@ class AccountApiController extends BaseAPIController
|
||||
{
|
||||
return $this->processLogin($request);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
);
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$data = $validator->messages();
|
||||
return $this->errorResponse($data);
|
||||
} else {
|
||||
$account = Auth::user()->account;
|
||||
$account->name = trim(Input::get('name'));
|
||||
$account->id_number = trim(Input::get('id_number'));
|
||||
$account->vat_number = trim(Input::get('vat_number'));
|
||||
$account->work_email = trim(Input::get('work_email'));
|
||||
$account->website = trim(Input::get('website'));
|
||||
$account->work_phone = trim(Input::get('work_phone'));
|
||||
$account->address1 = trim(Input::get('address1'));
|
||||
$account->address2 = trim(Input::get('address2'));
|
||||
$account->city = trim(Input::get('city'));
|
||||
$account->state = trim(Input::get('state'));
|
||||
$account->postal_code = trim(Input::get('postal_code'));
|
||||
$account->country_id = Input::get('country_id') ? Input::get('country_id') : null;
|
||||
$account->size_id = Input::get('size_id') ? Input::get('size_id') : null;
|
||||
$account->industry_id = Input::get('industry_id') ? Input::get('industry_id') : null;
|
||||
$account->email_footer = Input::get('email_footer');
|
||||
$account->save();
|
||||
|
||||
$transformer = new AccountTransformer(null, $request->serializer);
|
||||
$account = $this->createItem($account, $transformer, 'account');
|
||||
|
||||
return $this->response($account);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,17 @@ class BaseAPIController extends Controller
|
||||
return Response::make($response, 200, $headers);
|
||||
}
|
||||
|
||||
protected function errorResponse($response)
|
||||
{
|
||||
$error['error'] = $response;
|
||||
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
return Response::make($error, 400, $headers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function getIncluded()
|
||||
{
|
||||
$data = ['user'];
|
||||
|
@ -219,6 +219,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
||||
Route::post('login', 'AccountApiController@login');
|
||||
Route::get('static', 'AccountApiController@getStaticData');
|
||||
Route::get('accounts', 'AccountApiController@show');
|
||||
Route::put('accounts', 'AccountApiController@update');
|
||||
Route::resource('clients', 'ClientApiController');
|
||||
Route::get('quotes', 'QuoteApiController@index');
|
||||
Route::resource('quotes', 'QuoteApiController');
|
||||
|
Loading…
Reference in New Issue
Block a user