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