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