action = $action; $this->request = $request; $this->model = $bank; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(Bank $bank, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $bank = $bank->create($attributes); return $bank; } public function update(Bank $bank, array $request) { $attributes = $request; $bank->update($attributes); return $bank; } public function destroy(Bank $bank, array $request) { $bank->delete(); return $bank; } public function copy(Bank $bank, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $bank = $bank->replicate(); $bank->created_at = Carbon::now(); $bank->save(); return $bank; } for ($i = 1; $i <= $count; $i++) { $new = $bank->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $bank; } }