mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
33 lines
780 B
PHP
33 lines
780 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\Services;
|
|
|
|
use App\Classes\Exceptions\MalformedRequestException;
|
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
use App\Models\Company;
|
|
use App\Models\Segment;
|
|
use Illuminate\Database\QueryException;
|
|
|
|
class AssignsCompanyToSegment extends AbstractUpdateRecord
|
|
{
|
|
/**
|
|
* @param Company $company
|
|
* @param Segment $segment
|
|
* @return \Illuminate\Database\Eloquent\Model
|
|
* @throws MalformedRequestException
|
|
*/
|
|
public function execute(Company $company, Segment $segment)
|
|
{
|
|
try {
|
|
|
|
$company->segments()->attach($segment);
|
|
|
|
return $company;
|
|
|
|
} catch (QueryException $exception){
|
|
throw new MalformedRequestException($exception);
|
|
}
|
|
|
|
|
|
}
|
|
} |