model = $account; $function = Str::camel($action); event('litecms.contact.account.action.' . $action . 'ing', [$account]); $data = $this->$function($account, $request); event('litecms.contact.account.action.' . $action . 'ed', [$account]); $this->logsAction(); $this->notify(); return $data; } public function store(Account $account, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $account = $account->create($attributes); return $account; } public function update(Account $account, array $request) { $attributes = $request; $account->update($attributes); return $account; } public function delete(Account $account, array $request) { $account->delete(); return $account; } public function copy(Account $account, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $account = $account->replicate(); $account->created_at = Carbon::now(); $account->save(); return $account; } for ($i = 1; $i <= $count; $i++) { $new = $account->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $account; } }