Skip to content

Commit

Permalink
refactor(supplier): Add new fields to supplier
Browse files Browse the repository at this point in the history
- Fix header default company
- Upgrade composer dependencies
  • Loading branch information
gnovaro committed Nov 1, 2024
1 parent 3cef951 commit 38ed59a
Show file tree
Hide file tree
Showing 12 changed files with 617 additions and 597 deletions.
2 changes: 1 addition & 1 deletion app/Models/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Company extends Model
protected $with = ['country'];

#[OA\Property(property: 'name', description: 'Name of the company', type: 'string', example: 'My Company')]
public string $name;
public string $name = '';

#[OA\Property(property: 'business_name', description: 'Business Name of the company', type: 'string', example: 'My Company S.L')]
public string $business_name;
Expand Down
21 changes: 21 additions & 0 deletions app/Models/Supplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Supplier extends Model
'city',
'street',
'zipcode',
'notes',
'account_number',
'order_url',
'order_user',
'order_password',
];

protected $hidden = [
Expand Down Expand Up @@ -72,6 +77,22 @@ class Supplier extends Model
#[OAT\Property(type: 'string', example: 'EC4N 1SA')]
protected ?string $zipcode;

#[OAT\Property(type: 'string', example: 'This is a note')]
protected ?string $notes = null;

#[OAT\Property(type: 'string', example: '1234567890')]
protected ?string $account_number = null;

#[OAT\Property(type: 'string', example: 'https://supplier.com/order')]
protected ?string $order_url = null;

#[OAT\Property(type: 'string', example: 'username123')]
protected ?string $order_user = null;

#[OAT\Property(type: 'string', example: 'password123')]
protected ?string $order_password = null;


public function company()
{
return $this->belongsTo(Company::class);
Expand Down
5 changes: 5 additions & 0 deletions app/Repositories/SupplierRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function save(array $data): ?Supplier
$supplier->province = (! empty($data['province'])) ? $data['province'] : null;
$supplier->street = (! empty($data['street'])) ? $data['street'] : null;
$supplier->zipcode = (! empty($data['zipcode'])) ? $data['zipcode'] : null;
$supplier->notes = !empty($data['notes']) ? $data['notes'] : null;
$supplier->account_number = !empty($data['account_number']) ? $data['account_number'] : null;
$supplier->order_url = !empty($data['order_url']) ? $data['order_url'] : null;
$supplier->order_user = !empty($data['order_user']) ? $data['order_user'] : null;
$supplier->order_password = !empty($data['order_password']) ? $data['order_password'] : null;
$supplier->updated_at = now();
$supplier->save();

Expand Down
Loading

0 comments on commit 38ed59a

Please sign in to comment.