mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 08:54:34 -04:00
fixeS
This commit is contained in:
parent
08e4f9724f
commit
1986714927
@ -16,8 +16,6 @@ class EditClientRequest extends Request
|
|||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return $this->user()->can('edit', $this->client);
|
return $this->user()->can('edit', $this->client);
|
||||||
//return true;
|
|
||||||
// return ! auth()->user(); //todo permissions
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sanitize()
|
public function sanitize()
|
||||||
|
@ -27,10 +27,12 @@ class UpdateClientRequest extends Request
|
|||||||
|
|
||||||
$contacts = request('contacts');
|
$contacts = request('contacts');
|
||||||
|
|
||||||
for ($i = 0; $i < count($contacts); $i++) {
|
if(is_array($contacts))
|
||||||
$rules['contacts.' . $i . '.email'] = 'required|email|unique:client_contacts,email,' . $contacts[$i]['id'];
|
{
|
||||||
|
for ($i = 0; $i < count($contacts); $i++) {
|
||||||
|
$rules['contacts.' . $i . '.email'] = 'required|email|unique:client_contacts,email,' . $contacts[$i]['id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
Route::bind('client', function ($value) {
|
Route::bind('client', function ($value) {
|
||||||
$client = \App\Models\Client::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
$client = \App\Models\Client::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||||
//$client->load('contacts', 'primary_contact');
|
$client->with('contacts', 'primary_contact','country');
|
||||||
return $client;
|
return $client;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use App\Models\ClientContact;
|
|||||||
class ClientContactRepository extends BaseRepository
|
class ClientContactRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
|
|
||||||
public function save(array $contacts, Client $client) : void
|
public function save($contacts, Client $client) : void
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Convert array to collection */
|
/* Convert array to collection */
|
||||||
|
@ -32,6 +32,9 @@ class AccountTest extends TestCase
|
|||||||
Model::reguard();
|
Model::reguard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @covers AccountController
|
||||||
|
*/
|
||||||
public function testAccountCreation()
|
public function testAccountCreation()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -70,7 +70,10 @@ class ClientTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClientShow()
|
/*
|
||||||
|
* @covers ClientController
|
||||||
|
*/
|
||||||
|
public function testClientRestEndPoints()
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -118,6 +121,7 @@ class ClientTest extends TestCase
|
|||||||
});
|
});
|
||||||
|
|
||||||
$client = $account->default_company->clients()->first();
|
$client = $account->default_company->clients()->first();
|
||||||
|
$client->load('contacts');
|
||||||
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
@ -133,7 +137,27 @@ class ClientTest extends TestCase
|
|||||||
])->get('/api/v1/clients/'.$this->encodePrimaryKey($client->id).'/edit');
|
])->get('/api/v1/clients/'.$this->encodePrimaryKey($client->id).'/edit');
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
|
||||||
|
$client_update = [
|
||||||
|
'name' => 'A Funky Name'
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $token,
|
||||||
|
])->put('/api/v1/clients/'.$this->encodePrimaryKey($client->id), $client_update)
|
||||||
|
->assertJson([
|
||||||
|
'name' => 'A Funky Name'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $token,
|
||||||
|
])->delete('/api/v1/clients/'.$this->encodePrimaryKey($client->id));
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user