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