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