示例#1
0
 /**
  * Store a newly created resource in storage
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  * @throws RedirectException
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'token' => 'required|min:32|max:32']);
     $this->validateMerchantToken($request->only(['token'])['token'], $request->only(['name'])['name']);
     try {
         $merchant = Merchant::create($request->all());
         $this->merchantSynchronisationService->synchroniseMerchant($merchant->id, true);
     } catch (\Exception $e) {
         $this->logError('Could not successfully create new Merchant' . $e->getMessage());
         throw RedirectException::make('/merchants/')->setError($e->getMessage());
     }
     return $this->redirectWithSuccessMessage('/merchants/' . $merchant->id, 'New merchant has been successfully created');
 }
示例#2
0
 /**
  * @author EB
  * @param int $id
  * @param string $name
  * @param string $token
  * @return Merchant
  */
 public function createMerchant($id, $name, $token)
 {
     $merchant = new Merchant();
     $merchant->create(['id' => $id, 'name' => $name, 'token' => $token, 'created_at' => time(), 'updated_at' => time()]);
     return $merchant;
 }